gpt4 book ai didi

android - 当minifyEnabled为真时,如何在发布版本中修复 "NoSuchFieldException: No field producerIndex"- android?

转载 作者:行者123 更新时间:2023-12-03 13:26:11 26 4
gpt4 key购买 nike

调试应用程序工作正常。

但是,当使用 minifyEnabled true 构建发布应用程序时,应用程序会崩溃。

当我从 3.4.1 升级到“com.android.tools.build:gradle:3.4.2”的 Gradle 5 时会发生这种情况
(只能在启用了缩小的发布版本中重现。)

在 proguard-rules.pro 中试过这个

-keep public class org.ramanugen.gifex.** { public protected *; }

# Uncomment for DexGuard only
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule




#
#### RxJava, RxAndroid (https://gist.github.com/kosiara/487868792fbd3214f9c9)
#-keep class rx.schedulers.Schedulers {
# public static <methods>;
#}
#-keep class rx.schedulers.ImmediateScheduler {
# public <methods>;
#}
#-keep class rx.schedulers.TestScheduler {
# public <methods>;
#}
#-keep class rx.schedulers.Schedulers {
# public static ** test();
#}
#-keepclassmembers class rx.internal.util.unsafe.ArrayQueue*Field {
# long producerIndex;
# long consumerIndex;
#}
#-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
# long producerNode;
# long consumerNode;
#}

-keep class rx.** { *; }

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

忽略 rx 混淆。

在 proguard-rules.pro 中试过这个:
-ignorewarnings
-keep class ** {
public private *;
}

忽略所有混淆。

日志仍然被混淆。

minifyEnabled 为 false - 应用程序运行良好。(不是我正在寻找的解决方案)

下面是在启用最小化的情况下运行发布构建时的崩溃日志。
2019-07-22 18:02:40.868 13956-13956/? E/InputEventReceiver: Exception dispatching input event.
2019-07-22 18:02:40.868 13956-13956/? E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
2019-07-22 18:02:40.870 13956-13956/? E/MessageQueue-JNI: java.lang.InternalError
at g.d.d.b.z.a(Unknown Source:14)
at g.d.d.b.i.<clinit>(Unknown Source:4)
at g.d.d.d.a(Unknown Source:6)
at g.d.d.d.<init>(Unknown Source:16)
at g.d.d.d.<init>(Unknown Source:3)
at g.d.d.h.<init>(Unknown Source:0)
at g.d.d.j.<clinit>(Unknown Source:76)
at g.g.a(Unknown Source:0)
at org.ramanugen.gifex.view.GifGalleryView.a(Unknown Source:101)
at org.ramanugen.gifex.view.GifGalleryView.a(Unknown Source:94)
at com.gifskey.GifsScreen.b(Unknown Source:16)
at com.gifskey.q.e(Unknown Source:4)
at com.gifskey.q.a(Unknown Source:13)
at com.example.android.softkeyboard.SoftKeyboard.onKey(Unknown Source:68)
at android.inputmethodservice.KeyboardView.detectAndSendKey(KeyboardView.java:837)
at android.inputmethodservice.KeyboardView.onModifiedTouchEvent(KeyboardView.java:1342)
at android.inputmethodservice.KeyboardView.onTouchEvent(KeyboardView.java:1205)
at android.view.View.dispatchTouchEvent(View.java:11840)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:583)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1978)
at android.app.Dialog.dispatchTouchEvent(Dialog.java:837)
at android.inputmethodservice.SoftInputWindow.dispatchTouchEvent(SoftInputWindow.java:93)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:539)
at android.view.View.dispatchPointerEvent(View.java:12095)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4966)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4761)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4259)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4329)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4287)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4429)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4295)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4486)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4259)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4329)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4287)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4295)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4259)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6854)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6828)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6783)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6966)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:195)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:332)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:6792)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
2019-07-22 18:02:40.871 13956-13956/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.softkeyboard, PID: 13956
java.lang.InternalError
at g.d.d.b.z.a(Unknown Source:14)
at g.d.d.b.i.<clinit>(Unknown Source:4)
at g.d.d.d.a(Unknown Source:6)
at g.d.d.d.<init>(Unknown Source:16)
at g.d.d.d.<init>(Unknown Source:3)
at g.d.d.h.<init>(Unknown Source:0)
at g.d.d.j.<clinit>(Unknown Source:76)
at g.g.a(Unknown Source:0)
at org.ramanugen.gifex.view.GifGalleryView.a(Unknown Source:101)
at org.ramanugen.gifex.view.GifGalleryView.a(Unknown Source:94)
at com.gifskey.GifsScreen.b(Unknown Source:16)
at com.gifskey.q.e(Unknown Source:4)
at com.gifskey.q.a(Unknown Source:13)
at com.example.android.softkeyboard.SoftKeyboard.onKey(Unknown Source:68)
at android.inputmethodservice.KeyboardView.detectAndSendKey(KeyboardView.java:837)
at android.inputmethodservice.KeyboardView.onModifiedTouchEvent(KeyboardView.java:1342)
at android.inputmethodservice.KeyboardView.onTouchEvent(KeyboardView.java:1205)
at android.view.View.dispatchTouchEvent(View.java:11840)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3000)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2673)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:583)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1978)
at android.app.Dialog.dispatchTouchEvent(Dialog.java:837)
at android.inputmethodservice.SoftInputWindow.dispatchTouchEvent(SoftInputWindow.java:93)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:539)
at android.view.View.dispatchPointerEvent(View.java:12095)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4966)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4761)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4259)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4329)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4287)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4429)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4295)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4486)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4259)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4329)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4287)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4295)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4259)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6854)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6828)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6783)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6966)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:195)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:332)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:6792)
2019-07-22 18:02:40.871 13956-13956/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)
Caused by: java.lang.NoSuchFieldException: No field producerIndex in class Lg/d/d/b/i; (declaration of 'g.d.d.b.i' appears in /data/app/com.example.android.softkeyboard-NG4f5Iuo911KzcEsstiTLQ==/base.apk)
at java.lang.Class.getDeclaredField(Native Method)
at g.d.d.b.z.a(Unknown Source:0)

正如你在最后一行看到的
NoSuchFieldException: 没有字段 producerIndex
所以我尝试了
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
}

还是一样的崩溃

最佳答案

你走在正确的轨道上,看起来 ProGuard 缩小了 rxjava 类中的一些重要字段。看起来您正在使用 rxjava 1,它在某些情况下仍然使用反射。

我会将此依赖项添加到我的项目中,以便拥有修复所有可能问题的最新配置:

https://github.com/artem-zinnatullin/RxJavaProGuardRules

关于android - 当minifyEnabled为真时,如何在发布版本中修复 "NoSuchFieldException: No field producerIndex"- android?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57146355/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com