1

We're getting a strange exception for a smaller amount of devices where, apparently the class is not verified because of a method. Unfortunately we're not able to reproduce this with our devices and the stack trace is taken from Fabric.

The stack trace goes like this:

Fatal Exception: java.lang.VerifyError: Verifier rejected class com.example.library.-$$Lambda$d$QOXAMJpwehT8fF2Hmjjy5XM7Qx4: void com.example.library.-$$Lambda$d$QOXAMJpwehT8fF2Hmjjy5XM7Qx4.run(): [0xFFFFFFFF] wide register index out of range (15+1 >= 10) (declaration of 'com.example.library.-$$Lambda$d$QOXAMJpwehT8fF2Hmjjy5XM7Qx4' appears in /data/app/com.example.myapp-1/base.apk)
   at com.example.library.MyLibrary.initialize + 317(MyLibrary.java:317)
   at com.example.myapp.MyApp.onCreate + 152(MyApp.java:152)
   at android.app.Instrumentation.callApplicationOnCreate + 1024(Instrumentation.java:1024)
   at android.app.ActivityThread.handleBindApplication + 5581(ActivityThread.java:5581)
   at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(XposedBridge.java)
   at de.robv.android.xposed.XposedBridge.handleHookedMethod + 360(XposedBridge.java:360)
   at android.app.ActivityThread.handleBindApplication(ActivityThread.java)
   at android.app.ActivityThread.-wrap2(ActivityThread.java)
   at android.app.ActivityThread$H.handleMessage + 1579(ActivityThread.java:1579)
   at android.os.Handler.dispatchMessage + 102(Handler.java:102)
   at android.os.Looper.loop + 154(Looper.java:154)
   at android.app.ActivityThread.main + 6300(ActivityThread.java:6300)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 887(ZygoteInit.java:887)
   at com.android.internal.os.ZygoteInit.main + 777(ZygoteInit.java:777)
   at de.robv.android.xposed.XposedBridge.main + 107(XposedBridge.java:107)

The code at MyLibrary.java:317 looks like this:

executeOnBackground(() -> {
    // some code
}

Where the function is defined as this:

private static void executeOnBackground(Runnable runnable) {
    executeOnBackground(true, runnable);
}

Which internally calls this:

private static void executeOnBackground(boolean forcePost, Runnable runnable) {
    if (runnable == null)
        return;

    if (isOnMainThread() || forcePost)
        getNextBackgroundHandler().post(runnable);
    else
        runnable.run();
}

Note that the stack trace ends before it reaches the functions, so I assume the problem is in lambda functions? Or in the definition? I have no idea how to solve this, but it's the most frequent error that we're getting right now. It happens on random devices and Android OS version does not matter. So, if anyone can help or give some feedback, I'd be appreciated. Thanks.

Furkan Yurdakul
  • 2,801
  • 1
  • 15
  • 37

1 Answers1

0

Analysing the stacktrace shows that XPosed seems to be active which is a hooking framework. If you experience this errors only on some devices, it might be because some of your users try to hook your application and modify the code in the respective class MyLibrary.

T. Neidhart
  • 6,060
  • 2
  • 15
  • 38
  • Do you think the issue here is that users are manipulating the code? If so, then I can say that's their fault if they get exceptions, right? Or is there a way to prevent the exception from happening, without wrapping the code in try-catch? And I also assume then the code will throw the exception in another spot instead of the beginning. – Furkan Yurdakul Sep 23 '19 at 08:48
  • One thing you can do to verify if this is a problem with the app or somebody trying to modify it, is to extract the dex code for the `run` method of class `com.example.library.-$$Lambda$d$QOXAMJpwehT8fF2Hmjjy5XM7Qx4`, to see if there is anything suspicious there. A simple way to do that is to use apktool (https://ibotpeaches.github.io/Apktool/) and run `apktool d --no-res .apk`. Then find the code in `/smali/com/example/library/-$$Lambda$d$QOXAMJpwehT8fF2Hmjjy5XM7Qx4.smali`. If possible you can share that code with sgjesse@google.com, and I can take a look. – sgjesse Sep 23 '19 at 13:26