我在缩小我的应用程序时遇到错误。这是我从日志中得到的错误
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
它会起作用,但我确实需要混淆我的应用程序。我在这里错过了什么?我不认为我有相同的类(class)名称
最佳答案
我有同样的问题,通过删除解决了
-overloadaggressively
当我保留上面的内容并在其上方添加下面的行时,它也对我有用
-useuniqueclassmembernames
关于Android - 缩小应用程序在 com.android.dex.util.ExceptionWithContext 中创建错误(名称已添加 : string {"a"}),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40540359/