我从这个问题过去一周就陷入了困境。我正在尝试导出我的Android应用程序以进行最终发布,但它在导出时会出现以下错误。
Proguard returned with error code 1. See console
[2014-08-26 19:55:11 - ] Note: there were 1281 duplicate class definitions.
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced method 'android.app.RemoteInput[] getRemoteInputs()' in class android.app.Notification$Action
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced method 'android.os.Bundle getExtras()' in class android.app.Notification$Action
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced class android.app.Notification$Action$Builder
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced method 'java.lang.String getGroup()' in class android.app.Notification
[2014-08-26 19:55:11 - ] Warning: android.support.v4.app.NotificationCompatApi20: can't find referenced method 'java.lang.String getSortKey()' in class android.app.Notification
我在proguard-project.txt文件中使用以下条目。
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}
-keep class android.support.v4.** { *; }
-dontwarn **CompatHoneycomb
-dontwarn javax.jdo.**
-dontwarn com.google.api.client.extensions.android.**
-dontwarn com.google.api.client.googleapis.extensions.android.gms.**
# Needed by google-api-client-android when linking against an older platform version
-dontwarn com.google.api.client.googleapis.extensions.android.**
-injars lib/android-support-v4.jar
-injars lib/gcm.jar
-injars lib/google-api-client-1.18.0-rc.jar
-injars lib/google-api-client-android-1.18.0-rc.jar
-injars lib/google-http-client-1.18.0-rc.jar
-injars lib/google-http-client-android-1.18.0-rc.jar
-injars lib/google-http-client-gson-1.18.0-rc.jar
-injars lib/google-http-client-jackson2-1.18.0-rc.jar
-injars lib/google-http-client-jdo-1.18.0-rc.jar
-injars lib/google-oauth-client-1.18.0-rc.jar
-injars lib/gson-2.1.jar
-injars lib/jackson-core-2.1.3.jar
-injars lib/jsr305-1.3.9.jar
# Needed by google-play-services when linking against an older platform version
-dontwarn com.google.android.gms.**
如果我在proguard-project.txt文件中使用以下内容,我可以从eclipse成功导出我的.apk文件。但是当我在设备中安装并运行该应用程序时,它正在崩溃。
-keep class android.support.v4.** { *; }
-dontwarn android.support.v4.**
-dontwarn javax.activation.**
-dontwarn javax.security.**
-dontwarn java.awt.**
-libraryjars <java.home>/lib/rt.jar
-keep class javax.** {*;}
-keep class com.sun.** {*;}
-keep class myjava.** {*;}
-keep class org.apache.harmony.** {*;}
-keep public class Mail {*;}
-dontshrink
-dontwarn org.mockito.**
-dontwarn sun.reflect.**
-dontwarn android.test.**
-keep class javax.ws.rs.** { *; }
-dontwarn com.fasterxml.jackson.**
-dontwarn org.xmlpull.v1.**
-dontwarn javax.jdo.**
-dontwarn com.google.api.client.googleapis.extensions.android.gms.**
请帮帮我如何解决这个问题。我不能直接导出.apk文件而不使用proguard配置?谢谢。如果我需要提供更多信息,请告诉我。
答案 0 :(得分:3)
也许有些支持v4类或接口混淆了,我试过这个并且它可以工作
-dontwarn android.support.v4.**
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep public class * extends android.support.v4.**
-keep public class * extends android.app.Fragment
答案 1 :(得分:0)
我以这种方式成功解决了错误。
我的project.properties文件内容
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt:proguard-google-api-client.txt
# Project target.
target=android-19
android.library.reference.1=../appcompat_v7
我的proguard-project.txt内容
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
# added to prevent runtime errors (kazsato)
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-dontwarn javax.jdo.**
我的proguard-google-api-client.txt
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}
# Needed by google-http-client-android when linking against an older platform version
-dontwarn com.google.api.client.extensions.android.**
-dontwarn com.google.api.client.googleapis.extensions.android.gms.**
# Needed by google-api-client-android when linking against an older platform version
-dontwarn com.google.api.client.googleapis.extensions.android.**
# Needed by google-play-services when linking against an older platform version
-dontwarn com.google.android.gms.**
如果这个信息对某人有帮助,我会很高兴。我