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

标签 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 它会起作用,但我确实需要混淆我的应用程序。我在这里错过了什么?我不认为我有相同的类(class)名称

最佳答案

我有同样的问题,通过删除解决了

-overloadaggressively

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

-useuniqueclassmembernames

关于Android - 缩小应用程序在 com.android.dex.util.ExceptionWithContext 中创建错误(名称已添加 : string {"a"}),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40540359/

相关文章:

android - 如何在水平 ListView 中显示从 Web 服务检索到的 Json 文本和图像?

android - 使用签名的 APK 验证 DexGuard 配置

android - 在 android studio 中将模块用作 jar

android - 发布版本上的自定义 SearchView 崩溃

android - React Native MQTT.js 不适用于 Android 9+

android - 为什么使用 Unity 尝试拍照时相机 View 太宽且不清晰?

java - 解析 <Body>...</> 标签内的 HTML

java - 为什么 future.get() 对于 Volley RequestFuture 总是超时?

android - 无法在启用混淆器的情况下构建发布版本

java - 注意 : android. support.v4.app.NotificationCompat Jellybean 调用 'Field.getType'