Android Question error when I run my app on some device

MohammadNew

Active Member
Licensed User
Longtime User
Hello Erel , I used in my app Hijri converter date

On galaxy work , but lenovo does not work

give me error :

B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (addspend) Create, isFirst = true **
Error occurred on line: 79 (Addspend)
java.lang.NumberFormatException: Invalid double: "٢٠١٦"
    at java.lang.StringToReal.invalidReal(StringToReal.java:63)
    at java.lang.StringToReal.initialParse(StringToReal.java:164)
    at java.lang.StringToReal.parseDouble(StringToReal.java:282)
    at java.lang.Double.parseDouble(Double.java:301)
    at anywheresoftware.b4a.debug.RDebugUtils.numberCast(RDebugUtils.java:50)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at app.good.choice.addspend.afterFirstLayout(addspend.java:102)
    at app.good.choice.addspend.access$000(addspend.java:17)
    at app.good.choice.addspend$WaitForLayout.run(addspend.java:80)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5627)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
(Exception) java.lang.Exception:  java.lang.NumberFormatException: Invalid double: "٢٠١٦"
** Activity (addspend) Resume **
** Activity (addspend) Pause, UserClosed = false **
 

MohammadNew

Active Member
Licensed User
Longtime User
New logs :

B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (addspend) Create, isFirst = true **
Error occurred on line: 79 (Addspend)
java.lang.NumberFormatException: Invalid double: "٢٠١٦"
    at java.lang.StringToReal.invalidReal(StringToReal.java:63)
    at java.lang.StringToReal.initialParse(StringToReal.java:164)
    at java.lang.StringToReal.parseDouble(StringToReal.java:282)
    at java.lang.Double.parseDouble(Double.java:301)
    at anywheresoftware.b4a.debug.RDebugUtils.numberCast(RDebugUtils.java:50)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at app.good.choice.addspend.afterFirstLayout(addspend.java:102)
    at app.good.choice.addspend.access$000(addspend.java:17)
    at app.good.choice.addspend$WaitForLayout.run(addspend.java:80)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5627)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
(Exception) java.lang.Exception:  java.lang.NumberFormatException: Invalid double: "٢٠١٦"
Error occurred on line: 94 (Addspend)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:696)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at app.good.choice.addspend.afterFirstLayout(addspend.java:102)
    at app.good.choice.addspend.access$000(addspend.java:17)
    at app.good.choice.addspend$WaitForLayout.run(addspend.java:80)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5627)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
** Activity (addspend) Resume **
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
ok Erel , I am sorry and last time .

this is my code :

B4X:
Dim ss() As String
                   
        DateTime.DateFormat = "yyyy/MM/dd"
                       
        ss = Regex.Split("/",DateTime.Date(DateTime.now))
   
        Dim hijri As List=HijriConverter.GregorianToHijri(ss(0).Trim ,ss(1).Trim,ss(2).Trim)
              
        'EditText3.Text = hijri.Get(2) & "/" & NumberFormat(hijri.Get(1), 2 ,0) & "/" & NumberFormat(hijri.Get(0), 2 ,0)
       
        EditText3.Text = NumberFormat(hijri.Get(0), 2 ,0)       
        EditText4.Text = NumberFormat(hijri.Get(1), 2 ,0)        
        EditText5.Text = hijri.Get(2)

same code is working fine on my device galaxy , I tried on lenovo and htc does not work.

thanks alot
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Probably not going to be much help ... that code runs fine on samsung pad..

which code is on line 79 ? appears you are trying to pass a string to a method thats requires a Double data type / parameter ..
B4X:
Error occurred on line: 79 (Addspend)
java.lang.NumberFormatException: Invalid double: "٢٠١٦"
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
my code :
get datetime from device

then convert after that put the hijri date in edittext

on my device galaxy working fine .

Really , I published it and uploaded it on google play

now I have big problem I need to fix the problem and reupload again

79 this code :

B4X:
Dim hijri As List=HijriConverter.GregorianToHijri(ss(0).Trim ,ss(1).Trim,ss(2).Trim)
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I believe this is the line that is the problem ..
B4X:
EditText3.Text = hijri.Get(2) & "/" & NumberFormat(hijri.Get(1), 2 ,0) & "/" & NumberFormat(hijri.Get(0), 2 ,0)

The NumberFormat method expects a Double ... and on certain machines a String is passed (List hijri entry) ??????
 
Last edited:
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Thanks alot , but on my device galaxy is working fine!
Some devices does not work ???
Agree .. On my machine it is Ok .. The answer I do not Know.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It looks like this library doesn't handle the locale properly and returns a non-parseable string.

You can force the process locale with this code (put it in Starter.Service_Create):
B4X:
Dim jo As JavaObject
jo.InitializeStatic("java.util.Locale")
jo.RunMethod("setDefault", Array(jo.GetField("US")))
 
Upvote 0
Top