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
 

William Lancee

Well-Known Member
Licensed User
Longtime User
With ModuleDataArray.Initialize, it doesn't work
That's just my implementation of your class. You've got your own initialization somewhere else.
Or ModuleDataArray is a Code Module not a class.

Yes, I just tried in release mode and it work

We're getting somewhere. Try it with a sleep(50) as first line in MyMethod.
That should give spnSpinner1 time to load.
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
That's just my implementation of your class. You've got your own initialization somewhere else.
Yes, I added it to the module and called it from the starter but it still doesn't work

I had already tried with Sleep(50) before the call but the error appears before, the app does not start.

The only solution I see to make it work in debug mode is:

B4X:
    Try
        Private MyData As Double = spnSpinner1.SelectedItem
    Catch
        Log(LastException)
    End Try
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Lots of posts about working in debug, but not in release. Not many posts about the other way around.

I noticed that you have something like

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

I seem to remember something about NOT using methods in Process_Globals, and that it is related to problems in Debug mode.

I never put complicated assignments in Globals. So I don't know if that is OK.
Try putting the assignment elsewhere.
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
It happened again in another sub

B4X:
java.lang.RuntimeException: Unable to create service com.my_app.starter: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    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.reflect.InvocationTargetException
    at com.my_app.starter.onCreate(starter.java:39)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3953)
    ... 8 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at com.my_app.starter.onCreate(starter.java:37)
    ... 9 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(): [0xCD] 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 com.my_app.my_activity._process_globals(Unknown Source:0)
    at com.my_app.main.initializeProcessGlobals(main.java:2711)
    ... 11 more
java.lang.RuntimeException: Unable to create service com.my_app.starter: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    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.reflect.InvocationTargetException
    at com.my_app.starter.onCreate(starter.java:39)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3953)
    ... 8 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at com.my_app.starter.onCreate(starter.java:37)
    ... 9 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(): [0xCD] 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 com.my_app.my_activity._process_globals(Unknown Source:0)
    at com.my_app.main.initializeProcessGlobals(main.java:2711)
    ... 11 more

"Apparently" it is a problem in the conversion from String to Double while compiling the app, it does not always happen with a Spinner also with an EditText. If I comment out the lines where this conversion is done, the app compiles.

Any idea?
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Since neither @agraham nor I can replicate the problem, our only suggestion is to start with a skeleton project and add code from your app
until the problem occurs. (see #15 and #17). Then whatever you added causes the problem.
 
Upvote 0
Top