Android Question Invalid double: "null" after updating KeyValueStore

LucaMs

Expert
Licensed User
Longtime User
I was using an "old" version of KeyValueStore. Having found this problem:
https://www.b4x.com/android/forum/posts/557508/

I replaced the old class with the latest one (and replaced all PutSimple and GetSimple with Put and Get).

Running the project, I get:
java.lang.NumberFormatException: Invalid double: "null"

upload_2018-1-10_4-51-23.png


executing the assignment LastVersion = Version(0) (as you can see LastVersion is a string variable so this does not make sense [also Version is an array of strings]).

KeyValueStore is not involved in any part of this phase (GetOnlineVersion is a resumable sub which downloads a simple string from Internet, splits it and returns Version(), correctly).

How could this have happened?


Thank you
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
You should post the full error message from the logs.

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Error occurred on line: 269 (Main)
java.lang.NumberFormatException: Invalid double: "null"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.parseDouble(StringToReal.java:269)
at java.lang.Double.parseDouble(Double.java:295)
at anywheresoftware.b4a.debug.RDebugUtils.numberCast(RDebugUtils.java:50)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:19)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:240)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1717)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
try log(version (0)), and see what the output is.
Even if it is clear that the error cannot be there, because LastVersion is a String, so it can accept texts and numbers, I did it and the log is normal, 1.0.

I tried adding a Sleep(500) before the if test, just to see if in this way the error happened elsewhere but it's the same.

I will try to reproduce this situation in a test project (not now :(), but I think that in a new project this error will not happen; maybe attempting to do the same steps, ie initially adding the old class, run the project and then replacing the class.

[I'm stil "working" :)() with b4a 7.30 but this error happens with v. 7.80 too]
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Try
B4X:
LastVersion = Version(0).Replace(".",",")

Or

B4X:
LastVersion = "Ver." & Version(0)
 
Upvote 0
D

Deleted member 103

Guest
what happens in the sub "GetOnlineVersion"?
How is the variable version filled?
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
(GetOnlineVersion is a resumable sub which downloads a simple string from Internet, splits it and returns Version(), correctly).
Thank you
See if the error is not right in this ResumableSUb. It could go on with not having the necessary data yet.

Better if you put the sub GetOnlineVersion so we can see it
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Add some log messages:
B4X:
Wait For (...) ...
Log(Version)
Log(GetType(Version))
Log(Version(0))
Log(GetType(LastVersion))
Log("A: " & (LastVersion = Version(0)))

What is the output?
--------------------
[Ljava.lang.String;@21ec12d8
[Ljava.lang.String;
1.0
java.lang.String
java.lang.String
--------------------

This one crashes the app:
Log("A: " & (LastVersion = Version(0)))

LastVersion's value is its default value (Dim LastVersion As String = "") before that log, because the crash happens when I try to set it to Version(0)
 
Upvote 0
Top