Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MixPanelAPI NoClassDefFoundError

I'm struggling with java.lang.NoClassDefFoundError when invoking com.mixpanel.android.mpmetrics.MixpanelAPI

It is because I run proguard (I have to). However I added proguard exclusion:

-keep public class com.mixpanel.android.mpmetrics.**

or

-keep public class com.mixpanel.android.mpmetrics.MixpanelAPI { *; }

but it doesn't help.

Notice worth mentioning is that I get MixpanelAPI lib in that way:

        compile "com.mixpanel.android:mixpanel-android:4.0.0@aar"

So it's aar, not standard jar.

How to run it with proguard but not loosing Mixpanel code ?

like image 288
Adam Styrc Avatar asked Aug 03 '26 03:08

Adam Styrc


1 Answers

As of version 4.5, Mixpanel advises using the following proguard settings

-keep class com.mixpanel.android.abtesting.** { *; }
-keep class com.mixpanel.android.mpmetrics.** { *; }
-keep class com.mixpanel.android.surveys.** { *; }
-keep class com.mixpanel.android.util.** { *; }
-keep class com.mixpanel.android.java_websocket.** { *; }

-keepattributes InnerClasses

-keep class **.R
-keep class **.R$* {
    <fields>;
}

You can find these instructions in the README of the Mixpanel library, at https://github.com/mixpanel/mixpanel-android/blob/master/README.md in the changelog for version 4.5

like image 72
user128536 Avatar answered Aug 05 '26 19:08

user128536



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!