Android - 缩小应用程序会在com.android.dex.util.ExceptionWithContext中创建错误(已添加名称:字符串{" a"})

时间:2016-11-11 02:44:33

标签: android android-proguard

我在缩小应用时遇到错误。这是我从日志中得到的错误

Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}

这是我的计划规则

// I suspect the error is in one of these lines
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-verbose
-dontpreverify
-allowaccessmodification
-mergeinterfacesaggressively
-overloadaggressively

// End of the suspected lines

-keep class com.testapp.www.** {*;}

# Keep SafeParcelable value, needed for reflection. This is required to support backwards
# compatibility of some classes.
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

# Keep the names of classes/members we need for client functionality.
-keep @interface com.google.android.gms.common.annotation.KeepName
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

# Needed for Parcelable/SafeParcelable Creators to not get stripped
-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

# Needed when building against pre-Marshmallow SDK.
-dontwarn android.security.NetworkSecurityPolicy

# Keep metadata about included modules.
-keep public class com.google.android.gms.dynamite.descriptors.** {
  public <fields>;
}

# Keep the implementation of the flags api for google-play-services-flags

-keep public class com.google.android.gms.flags.impl.FlagProviderImpl {
  public <fields>; public <methods>;
}

-keep class com.yalantis.ucrop** { *; }
-keep interface com.yalantis.ucrop** { *; }

-keepattributes InnerClasses, EnclosingMethod
-keep class com.makeramen.roundedimageview** { *; }
# Ensure annotations are kept for runtime use.
-keepattributes *Annotation*
# Don't remove any GreenRobot classes
-keep class de.greenrobot.** {*;}
# Don't remove any methods that have the @Subscribe annotation
-keepclassmembers class ** {
    @de.greenrobot.event.Subscribe <methods>;
}

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# Gson specific classes
-keep class sun.misc.** { *; }
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
# default
-keep class com.sample.package.models.** { *; } # sample only cant public package right now
##---------------End: proguard configuration for Gson  ----------

-keep class com.google.gson
-keep class Gson**
-keepclassmembers class Gson** {
    *;
}
## OkHttp
-keep class okhttp3.internal.** { *; }
-dontwarn okhttp3.internal.**
## okio?
-keep class java.nio.file.** { *; }
-dontwarn java.nio.file.**
-keep class org.codehaus.mojo.animal_sniffer.** { *; }
-dontwarn org.codehaus.mojo.animal_sniffer.**
## Android Graphics
-keep class org.xmlpull.v1.** { *; }
-dontwarn org.xmlpull.v1.**

如果我添加规则-dontobfuscate,它可以正常工作,但我确实需要对我的应用进行模糊处理。我在这里错过了什么?我不认为我有相同的班级名称

1 个答案:

答案 0 :(得分:3)

我有同样的问题并通过删除

解决了这个问题
-overloadaggressively

当我保留上述内容并在其上方添加以下行时,它也对我有用

-useuniqueclassmembernames