Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard and RxAndroid V1.1.0

I can't seem to get Proguard working with the RxAndroid v1.1.0 library.

Previously I have been using v1.0.1 and this worked fine with the following rule.

-dontwarn rx.internal.util.unsafe.**

However after upgrading to v1.1.0 of rxAndroid and also including RxJava as it says on the Github ReadMe.txt, I get this exception whenever I use RxAndroid in my code.

Caused by: java.lang.NoSuchFieldException: producerIndex

So I added more Proguard rules like people have said in some of the issue reports on the Github.

-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;
}

-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;
}

-dontwarn rx.internal.util.unsafe.**

This does not work and I continually get the crashes when I generate the release builds. Any idea as I would like to use the latest libraries.

like image 473
StuStirling Avatar asked Dec 16 '15 15:12

StuStirling


2 Answers

I add the following code in proguard file.

-keepclassmembers class rx.internal.util.unsafe.** {
    long producerIndex;
    long consumerIndex;
}
like image 169
0Kai Avatar answered Oct 04 '22 00:10

0Kai


You should try with

 -keep class * {
        public private *;
    }
     # rxjava
    -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;
    }
like image 33
IntelliJ Amiya Avatar answered Oct 04 '22 00:10

IntelliJ Amiya