Debug app is working fine.
But when release app is build with minifyEnabled true, app gets crashed.
This happens when I upgraded to Gradle 5 which is 'com.android.tools.build:gradle:3.4.2' from 3.4.1 (Reproducible only in release builds with minify enabled.)
Tried this in 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
to ignore rx obfuscation.
Tried this in proguard-rules.pro:
-ignorewarnings
-keep class ** {
public private *;
}
to ignore all obfuscation.
Still logs are obfuscated.
minifyEnabled to false - app works fine.(not the solution I'm looking for)
Below are the crash logs when running release build with minified enabled.
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)
As you can see in the last line NoSuchFieldException: No field producerIndex So I tried
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
}
Still same crash
You were on the right track and it looks like ProGuard minified away some important fields from rxjava classes. It looks like you are using rxjava 1, which still used reflection in certain cases.
I would add this dependency to my project in order to have up-to-date configurations that fix all of the possible issues:
https://github.com/artem-zinnatullin/RxJavaProGuardRules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With