【Android-Error】Caused by: java.lang.NoSuchFieldException: No field producerIndex.....ProducerFields

使用RxJava库,在DebugAPK中运行得很好,但是当正式签名发布时候。出现崩溃。原因如下:

Caused by: java.lang.NoSuchFieldException: 
No field producerIndex in class Lrx/internal/util/unsafe/SpscArrayQueueProducerFields;

该错误是RxJava代码被混淆的问题 需要在混淆的时候添加

-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;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
    long producerNode;
    long consumerNode;
}
-keep class rx.schedulers.Schedulers {
    public static ;
}
-keep class rx.schedulers.Schedulers {
    public static ** test();
}
-keep class rx.schedulers.ImmediateScheduler {
    public ;
}
-keep class rx.schedulers.TestScheduler {
    public ;
}

你可能感兴趣的:(问题汇总)