作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
调试应用程序工作正常。
但是,当使用 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
-ignorewarnings
-keep class ** {
public private *;
}
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)
-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/
调试应用程序工作正常。 但是,当使用 minifyEnabled true 构建发布应用程序时,应用程序会崩溃。 当我从 3.4.1 升级到“com.android.tools.build:gradl
我是一名优秀的程序员,十分优秀!