When trying to update an app (the last update was 10 months ago) and I get this error:
B4X:
java.lang.VerifyError: Verifier rejected class com.my_app: java.lang.String com.my_app._my_method() failed to verify: java.lang.String com.my_app._my_method(): [0x268] Rejecting invocation, long or double parameter at index 0 is not a pair: 15 + 0. (declaration of 'com.my_app' appears in base.apk!classes2.dex)
B4X:
Sub My_method
Dim MyData As Double = spnSpinner1.SelectedItem
....
End Sub
log(MyDataStr & TAB & MyDataStr.length)
Dim MyData As Double = MyDataStr.As(Double)
'Same as
Dim MyData As Double = MyDataStr
'Both will fail if MyDataStr.Length = 0 or MyDataStr has non-numeric characters (for example $,_: or - in the middle)
Not much to go on then. Which of the two lines in #3 causes the compile error?
1. is spnSpinner initialized
2. is MyDataStr used elsewhere with a different cast than string (or as an array)
3. is MyData used elsewhere with a different cast than double (or as an array)
4. does Dim MyDataInt As Int = MyDataStr work?
Copying updated assets files (1)
java.lang.VerifyError: Verifier rejected class com.my_app.my_activity: java.lang.String com.my_app.my_activity._my_method() failed to verify: java.lang.String com.my_app.my_activity._my_method(): [0x288] Rejecting invocation, long or double parameter at index 0 is not a pair: 15 + 0. (declaration of 'com.my_app.my_activity' appears in base.apk!classes2.dex)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:624)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:726)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at com.my_app.starter.onCreate(starter.java:48)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3953)
at android.app.ActivityThread.access$1500(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)
java.lang.RuntimeException: Unable to create service com.my_app.starter: java.lang.RuntimeException: java.lang.VerifyError: Verifier rejected class com.my_app.my_activity: java.lang.String com.my_app.my_activity._my_method() failed to verify: java.lang.String com.my_app.my_activity._my_method(): [0x288] Rejecting invocation, long or double parameter at index 0 is not a pair: 15 + 0. (declaration of 'com.my_app.my_activity' appears in base.apk!classes2.dex)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3965)
at android.app.ActivityThread.access$1500(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)
Caused by: java.lang.RuntimeException: java.lang.VerifyError: Verifier rejected class com.my_app.my_activity: java.lang.String com.my_app.my_activity._my_method() failed to verify: java.lang.String com.my_app.my_activity._my_method(): [0x288] Rejecting invocation, long or double parameter at index 0 is not a pair: 15 + 0. (declaration of 'com.my_app.my_activity' appears in base.apk!classes2.dex)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:175)
at com.my_app.starter.onCreate(starter.java:48)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3953)
... 8 more
Caused by: java.lang.VerifyError: Verifier rejected class com.my_app.my_activity: java.lang.String com.my_app.my_activity._my_method() failed to verify: java.lang.String com.my_app.my_activity._my_method(): [0x288] Rejecting invocation, long or double parameter at index 0 is not a pair: 15 + 0. (declaration of 'com.my_app.my_activity' appears in base.apk!classes2.dex)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:624)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:726)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
... 10 more
java.lang.RuntimeException: Unable to create service com.my_app.starter: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3965)
at android.app.ActivityThread.access$1500(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at com.my_app.starter.onCreate(starter.java:34)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3953)
... 8 more
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
at anywheresoftware.b4a.shell.ShellConnector.sendControlMessage(ShellConnector.java:61)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:124)
... 12 more
Not much to go on then. Which of the two lines in #3 causes the compile error?
1. is spnSpinner initialized
2. is MyDataStr used elsewhere with a different cast than string (or as an array)
3. is MyData used elsewhere with a different cast than double (or as an array)
4. does Dim MyDataInt As Int = MyDataStr work?
In post #5 you said it happens during compilation but post #7 looks like a runtime error to me. Which is it?
Is spnSpinner1 a standard Spinner and what is the type of the items you are adding to it? Show the code fragment that adds the items to the Spinner including the Dims for those objects.
Is spnSpinner1 a standard Spinner and what is the type of the items you are adding to it? Show the code fragment that adds the items to the Spinner including the Dims for those objects.
Sub Process_Globals
Log("Main.Process_Globals")
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("LoadLayout1")
'....
End Sub
My_module:
Sub Globals
Private spnSpinner1 As Spinner
'......
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout1")
spnSpinner1.Clear
spnSpinner1.AddAll(ModuleDataArray.ArraySpinner )
'....
My_method
End Sub
Sub My_method
Dim MyData As Double = spnSpinner1.SelectedItem
'....
End Sub
ModuleDataArray:
Sub Process_Globals
Log("ModuleDataArray.Process_Globals")
Public ArraySpinner As List = Array As String("15", "30", "45", "50", "75", "100", "112.5", "150", "160", "225", "200", "250", "300", "315", "400", "500", "630", "750", "800", "1000", "1250", "1500", "1600", "2000", "2500")
Log("Items spinner: " & ArraySpinner.Size)
End Sub
Starter:
Sub Process_Globals
Log("Starter.Process_Globals")
End Sub
When trying to update an app (the last update was 10 months ago) and I get this error:
B4X:
java.lang.VerifyError: Verifier rejected class com.my_app: java.lang.String com.my_app._my_method() failed to verify: java.lang.String com.my_app._my_method(): [0x268] Rejecting invocation, long or double parameter at index 0 is not a pair: 15 + 0. (declaration of 'com.my_app' appears in base.apk!classes2.dex)
B4X:
Sub My_method
Dim MyData As Double = spnSpinner1.SelectedItem
....
End Sub
The Java Virtual Machine (JVM) distrusts all loaded bytecode as a core tenet of the Java Security Model. During runtime, the JVM will load .class files and attempt to link them together to form an executable — but the validity of these loaded .class files is unknown.
To ensure that the loaded .class files do not pose a threat to the final executable, the JVM performs verification on the .class files. Additionally, the JVM ensures that binaries are well-formed. For example, the JVM will verify classes do not subtype final classes.
In many cases, verification fails on valid, non-malicious bytecode because a newer version of Java has a stricter verification process than older versions.
Thus, when linking older .class files with a newer JVM, the JVM may throw a java.lang.VerifyError
There is one item in your spinner list that could cause an error if you have your locale set to use the alternative number format (12.123.123,39).
"112.5"
That's probably why the answer to "Does Dim MyDataInt As Int = MyDataStr work?" is YES
I also tried to replicate the problem, but no luck. Did you try it in release mode?
While in debug mode the first time, I saw something similar to your error.
Note that the assignment statement happens early in the Activity, before anything is really selected.
Maybe the layout is not fully loaded?
B4X:
Sub Process_Globals
Public ArraySpinner As List
Private ModuleDataArray As ModuleDataArrayCls1
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private spnSpinner1 As Spinner
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
ModuleDataArray.Initialize
spnSpinner1.Clear
spnSpinner1.AddAll(ModuleDataArray.ArraySpinner)
Dim MyData As Double = spnSpinner1.SelectedItem
Log(MyData) 'nothing is selected yet - default is first item - i.e. 15
End Sub
B4X:
Sub Class_Globals
Public ArraySpinner As List = Array As String("15", "30", "45", "50", "75", "100", "112,5", "150", "160", "225", "200", "250", "300", "315", "400", "500", "630", "750", "800", "1000", "1250", "1500", "1600", "2000", "2500")
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
End Sub
There is one item in your spinner list that could cause an error if you have your locale set to use the alternative number format (12.123.123,39).
"112.5"
That's probably why the answer to "Does Dim MyDataInt As Int = MyDataStr work?" is YES
While in debug mode the first time, I saw something similar to your error.
Note that the assignment statement happens early in the Activity, before anything is really selected.
Maybe the layout is not fully loaded?