MixPanelAPI NoClassDefFoundError

丶灬走出姿态 提交于 2019-12-05 06:16:03

问题


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 ?


回答1:


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




回答2:


This could be the solution:

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



回答3:


In my case the problem was in incorrect MultiDex implementation, I solve it after add to main class MultiDex.install(this);

public class MyMainClass extends Application {
    @Override
    public void onCreate() {
        MultiDex.install(this);
...
}


来源:https://stackoverflow.com/questions/25663713/mixpanelapi-noclassdeffounderror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!