0

After activating proguard for my android aplication in android studio, the app crashes with error says cannot find Mypackage.Application class.

MyApplication classs extends MultiDexApplication.

Here is the error I got and below is my proguard-rules.pro file:

-libraryjars <java.home>/lib/rt.jar(javax/**)
-keepattributes *Annotation*,InnerClasses,EnclosingMethod,Signature

-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-dontwarn rx.**
-dontwarn retrofit.**
-dontwarn okio.**
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
   @retrofit.http.* <methods>;
}

-keepnames class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.databind.**

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application

-dontwarn com.marshalchen.ultimaterecyclerview.animators.BaseItemAnimator
-dontwarn com.google.appengine.api.urlfetch.**
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry.**

and here is MyAplication class:

public class MyApplication extends MultiDexApplication {
private static Context mContext;

public static Context getContext() {
    return mContext;
}

@Override
public void onCreate() {
    super.onCreate();
    mContext = getApplicationContext();

    AnalyticsTrackers.initialize(mContext);
  }
}

What is the solution?

user5510211
  • 297
  • 1
  • 3
  • 13

1 Answers1

0
--keepresourcefiles AndroidManifest.xml

this is default by proguard but you can give a try.

Silvans Solanki
  • 1,267
  • 1
  • 14
  • 27
  • Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. > java.io.IOException: proguard.ParseException: Unknown option '-keepresourcefiles' in line 34 of file '/Users/Amir/AndroidStudioProjects/jarchiapp/app/proguard-rules.pro' – user5510211 Mar 14 '16 at 08:50
  • Can you post your Multidex application class here? – Silvans Solanki Mar 14 '16 at 09:44
  • I posted MyAplication class, take a look – user5510211 Mar 14 '16 at 14:10