gpt4 book ai didi

android - 使用仅在发布时使用 RxJava 的库时应用程序崩溃

转载 作者:行者123 更新时间:2023-12-04 00:30:39 25 4
gpt4 key购买 nike

我用过this我的应用程序中的库该库本身使用 RxJava,它在 Debug APK 中完美运行。当 Proguard 混淆被禁用时,它甚至可以在 Release 上工作。但是当我选择图像后启用 Proguard 时它会停止工作!

这是日志:

08-02 22:54:11.848: E/AndroidRuntime(17818): FATAL EXCEPTION: main 08-02 22:54:11.848: E/AndroidRuntime(17818): Process: com.domus.safariar.domus, PID: 17818 08-02 22:54:11.848: E/AndroidRuntime(17818): java.lang.InternalError 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.internal.util.unsafe.UnsafeAccess.addressOf(Unknown Source:14) 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.internal.util.unsafe.SpscArrayQueueProducerFields.(Unknown Source:4) 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.(Unknown Source:50) 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.internal.operators.OperatorObserveOn.call(Unknown Source:22) 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.internal.operators.OperatorObserveOn.call(Unknown Source:2) 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.Observable$2.call(Unknown Source:8) 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.Observable$2.call(Unknown Source:2) 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.Observable.subscribe(Unknown Source:43) 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.Observable.subscribe(Unknown Source:0) 08-02 22:54:11.848: E/AndroidRuntime(17818): at com.zfdang.multiple_images_selector.ImagesSelectorActivity.LoadFolderAndImages(Unknown Source:36) 08-02 22:54:11.848: E/AndroidRuntime(17818): at com.zfdang.multiple_images_selector.ImagesSelectorActivity.onRequestPermissionsResult(Unknown Source:48) 08-02 22:54:11.848: E/AndroidRuntime(17818): at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7429) 08-02 22:54:11.848: E/AndroidRuntime(17818): at android.app.Activity.dispatchActivityResult(Activity.java:7280) 08-02 22:54:11.848: E/AndroidRuntime(17818): at android.app.ActivityThread.deliverResults(ActivityThread.java:4264) 08-02 22:54:11.848: E/AndroidRuntime(17818): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312) 08-02 22:54:11.848: E/AndroidRuntime(17818): at android.app.ActivityThread.-wrap19(Unknown Source:0) 08-02 22:54:11.848: E/AndroidRuntime(17818): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644) 08-02 22:54:11.848: E/AndroidRuntime(17818): at android.os.Handler.dispatchMessage(Handler.java:106) 08-02 22:54:11.848: E/AndroidRuntime(17818): at android.os.Looper.loop(Looper.java:164) 08-02 22:54:11.848: E/AndroidRuntime(17818): at android.app.ActivityThread.main(ActivityThread.java:6494) 08-02 22:54:11.848: E/AndroidRuntime(17818): at java.lang.reflect.Method.invoke(Native Method) 08-02 22:54:11.848: E/AndroidRuntime(17818): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 08-02 22:54:11.848: E/AndroidRuntime(17818): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 08-02 22:54:11.848: E/AndroidRuntime(17818): Caused by: java.lang.NoSuchFieldException: No field producerIndex in class Lrx/internal/util/unsafe/SpscArrayQueueProducerFields; (declaration of 'rx.internal.util.unsafe.SpscArrayQueueProducerFields' appears in /data/app/com.domus.safariar.domus-P04AN9pLul9iY1dryJ3vXg==/base.apk!classes3.dex) 08-02 22:54:11.848: E/AndroidRuntime(17818): at java.lang.Class.getDeclaredField(Native Method) 08-02 22:54:11.848: E/AndroidRuntime(17818): at rx.internal.util.unsafe.UnsafeAccess.addressOf(Unknown Source:0) 08-02 22:54:11.848: E/AndroidRuntime(17818): ... 22 more 08-02 22:54:11.849: E/UncaughtException(17818): java.lang.InternalError 08-02 22:54:11.849: E/UncaughtException(17818): at rx.internal.util.unsafe.UnsafeAccess.addressOf(Unknown Source:14) 08-02 22:54:11.849: E/UncaughtException(17818): at rx.internal.util.unsafe.SpscArrayQueueProducerFields.(Unknown Source:4) 08-02 22:54:11.849: E/UncaughtException(17818): at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.(Unknown Source:50) 08-02 22:54:11.849: E/UncaughtException(17818): at rx.internal.operators.OperatorObserveOn.call(Unknown Source:22) 08-02 22:54:11.849: E/UncaughtException(17818): at rx.internal.operators.OperatorObserveOn.call(Unknown Source:2) 08-02 22:54:11.849: E/UncaughtException(17818): at rx.Observable$2.call(Unknown Source:8) 08-02 22:54:11.849: E/UncaughtException(17818): at rx.Observable$2.call(Unknown Source:2) 08-02 22:54:11.849: E/UncaughtException(17818): at rx.Observable.subscribe(Unknown Source:43) 08-02 22:54:11.849: E/UncaughtException(17818): at rx.Observable.subscribe(Unknown Source:0) 08-02 22:54:11.849: E/UncaughtException(17818): at com.zfdang.multiple_images_selector.ImagesSelectorActivity.LoadFolderAndImages(Unknown Source:36) 08-02 22:54:11.849: E/UncaughtException(17818): at com.zfdang.multiple_images_selector.ImagesSelectorActivity.onRequestPermissionsResult(Unknown Source:48) 08-02 22:54:11.849: E/UncaughtException(17818): at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7429) 08-02 22:54:11.849: E/UncaughtException(17818): at android.app.Activity.dispatchActivityResult(Activity.java:7280) 08-02 22:54:11.849: E/UncaughtException(17818): at android.app.ActivityThread.deliverResults(ActivityThread.java:4264) 08-02 22:54:11.849: E/UncaughtException(17818): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312) 08-02 22:54:11.849: E/UncaughtException(17818): at android.app.ActivityThread.-wrap19(Unknown Source:0) 08-02 22:54:11.849: E/UncaughtException(17818): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644) 08-02 22:54:11.849: E/UncaughtException(17818): at android.os.Handler.dispatchMessage(Handler.java:106) 08-02 22:54:11.849: E/UncaughtException(17818): at android.os.Looper.loop(Looper.java:164) 08-02 22:54:11.849: E/UncaughtException(17818): at android.app.ActivityThread.main(ActivityThread.java:6494) 08-02 22:54:11.849: E/UncaughtException(17818): at java.lang.reflect.Method.invoke(Native Method) 08-02 22:54:11.849: E/UncaughtException(17818): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 08-02 22:54:11.849: E/UncaughtException(17818): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 08-02 22:54:11.849: E/UncaughtException(17818): Caused by: java.lang.NoSuchFieldException: No field producerIndex in class Lrx/internal/util/unsafe/SpscArrayQueueProducerFields; (declaration of 'rx.internal.util.unsafe.SpscArrayQueueProducerFields' appears in /data/app/com.domus.safariar.domus-P04AN9pLul9iY1dryJ3vXg==/base.apk!classes3.dex) 08-02 22:54:11.849: E/UncaughtException(17818): at java.lang.Class.getDeclaredField(Native Method) 08-02 22:54:11.849: E/UncaughtException(17818): at rx.internal.util.unsafe.UnsafeAccess.addressOf(Unknown Source:0) 08-02 22:54:11.849: E/UncaughtException(17818): ... 22 more



我试图添加一些 Proguard 规则以避免崩溃,但它不起作用:
-keep class * {
public private *;
}

-keep class com.facebook.** { *; }

-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 com.zfdang.multiple_images_selector.ImagesSelectorActivity**{*;}
-keep class com.zfdang.multiple_images_selector.ImagesSelectorActivity$**{*;}
-dontwarn com.zfdang.multiple_images_selector.ImagesSelectorActivity**{*;}
-keep com.zfdang.multiple_images_selector.ImagesSelectorActivity.LoadFolderAndImages**{*;}
-dontwarn com.zfdang.multiple_images_selector.ImagesSelectorActivity.LoadFolderAndImages**{*;}
-keep class rx.internal.operators.OperatorObserveOn**{*;}
-dontwarn rx.internal.operators.OperatorObserveOn.**

最佳答案

-dontwarn sun.misc.** 

-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { rx.internal.util.atomic.LinkedQueueNode producerNode;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { rx.internal.util.atomic.LinkedQueueNode consumerNode;
}
-dontnote rx.internal.util.PlatformDependent

请尝试将缺失的行添加到您的 proguard 规则中。

关于android - 使用仅在发布时使用 RxJava 的库时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51660189/

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