Android Question Failed to verify: java.lang.String

angel_

Well-Known Member
Licensed User
Longtime User
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
 

angel_

Well-Known Member
Licensed User
Longtime User
I tried this but it doesn't work either:

B4X:
Dim MyDataStr As String = spnSpinner1.SelectedItem
Dim MyData As Double = MyDataStr.As(Double)
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Report your error and log.
B4X:
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)
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
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?
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
This is the full log
B4X:
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

1. From designer
2. No
3. No
4. Yes
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Try:
B4X:
Dim MyDataStr As String = spnSpinner1.SelectedItem
Dim MyData As Double
Try
            MyData=MyDataStr
Catch
            Log(myDataStr)            
            Log(LastException)
End Try

The 15+0 which I see, is suspicious. Is this an item of your spinner?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
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.
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
In post #5 you said it happens during compilation but post #7 looks like a runtime error to me. Which is it?
I'm sorry I don't know the difference, it occurs during the start of the application, it doesn't complete 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.
Yes, it is a standard spinner

Logs:
Copying updated assets files (1)
Main.Process_Globals
ModuleDataArray.Process_Globals    'Load data to add spinner later
Items array: 25
Starter.Process_Globals
java.lang.VerifyError: Verifier rejected class...
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
Main:
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
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
allow me to add to the confusion:

from https://www.baeldung.com/java-lang-verifyerror

op starts thread by referring to having updated an old app.
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
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
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
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
 
Last edited:
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
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 have tried this but it doesn't work either:

B4X:
Public ArraySpinner As List = Array As String("15", "30", "45", "50", "75", "100", "112", "150"...

If I declare the variable like Int yes it works
 
Last edited:
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
I also tried to replicate the problem, but no luck. Did you try it in release mode?
Yes, I just tried in release mode and it works

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?
With ModuleDataArray.Initialize, it doesn't work
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…