对于较少数量的设备,我们遇到了一个奇怪的异常,显然该类由于方法而未验证。不幸的是,我们无法用我们的设备重现这一点,并且堆栈跟踪来自 Fabric。
堆栈跟踪如下所示:
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)
MyLibrary.java:317中的代码如下所示:
executeOnBackground(() -> {
// some code
}
函数定义如下:
private static void executeOnBackground(Runnable runnable) {
executeOnBackground(true, runnable);
}
内部称之为:
private static void executeOnBackground(boolean forcePost, Runnable runnable) {
if (runnable == null)
return;
if (isOnMainThread() || forcePost)
getNextBackgroundHandler().post(runnable);
else
runnable.run();
}
请注意,堆栈跟踪在到达函数之前就结束了,所以我认为问题出在 lambda 函数中?还是在定义中?我不知道如何解决这个问题,但这是我们现在遇到的最常见的错误。它发生在随机设备上,Android OS 版本无关紧要。因此,如果有人可以提供帮助或提供一些反馈,我将不胜感激。谢谢。