Android proguard使用Multidex

时间:2016-04-30 07:44:54

标签: android proguard multidex

我尝试将proguard用于我的Android应用程序。我在我的应用中使用了multidex,所以我在build.gradle中添加了multiDexEnabled = true但是当我尝试构建apk时,我收到了以下错误:

Error:Execution failed for task 
':app:transformClassesWithMultidexlistForRelease'.
> expected one element but was: 
</Users/Amir/AndroidStudioProjects/jarchiapp/app/build/intermediates/transforms/proguard/release/jars/3/1f/butterknife-7.0.1.jar, 
/Users/Amir/AndroidStudioProjects/jarchiapp/app/build/intermediates/transforms/proguard/release/jars/3/1f/classes.jar, 
/Users/Amir/AndroidStudioProjects/jarchiapp/app/build/intermediates/transforms/proguard/release/jars/3/1f/commons-codec-1.10.jar, 
/Users/Amir/AndroidStudioProjects/jarchiapp/app/build/intermediates/transforms/proguard/release/jars/3/1f/disklrucache-2.0.2.jar, 
/Users/Amir/AndroidStudioProjects/jarchiapp/app/build/intermediates/transforms/proguard/release/jars/3/1f/dualcache-2.2.0.jar, ...>

这是我的proguard-ruls.pro:

-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 class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }

-keepclasseswithmembernames class * {
  @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
   @butterknife.* <methods>;
}

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

-dontwarn javax.management.**
-dontwarn java.lang.management.**
-dontwarn org.apache.log4j.**
-dontwarn org.apache.commons.logging.**
-dontwarn org.slf4j.**
-dontwarn org.json.**

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }

-keepclasseswithmembernames class * {
  native <methods>;
}

-keepclasseswithmembernames class * {
   public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
  public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
  public static **[] values();
  public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

问题是什么,如何解决?

1 个答案:

答案 0 :(得分:0)

你看过这个讨论了吗?

Android support multidex library implementation

顺便说一下。我认为这不是一个问题......