java.lang.VerifyError on an obfuscated Android library

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.

android
proguard
android-library
r8
asked on Stack Overflow Sep 23, 2019 by Furkan Yurdakul

1 Answer

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.

answered on Stack Overflow Sep 23, 2019 by T. Neidhart

User contributions licensed under CC BY-SA 3.0