我在我的应用程序中使用外部库,例如 foursquare api 和 ABS 库。
当我在导出应用程序之前启用混淆器时,我在控制台中收到下面提到的错误。
Proguard returned with error code 1. See console Note: there were 3686 duplicate class definitions. Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions$Builder Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions$Builder Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse You should check if you need to specify additional program jars. Warning: there were 35 unresolved references to classes or interfaces. You may need to specify additional library jars (using '-libraryjars'). java.io.IOException: Please correct the above warnings first. at proguard.Initializer.execute(Initializer.java:321) at proguard.ProGuard.initialize(ProGuard.java:211) at proguard.ProGuard.execute(ProGuard.java:86) at proguard.ProGuard.main(ProGuard.java:492)
我知道我必须在 Proguard 属性文件中提及外部库。怎么提才是问题。
请看我的proguard文件
-injars bin/classes
-outjars bin/classes-processed.jar
-libraryjars E:/android/adt-bundle-windows-x86_64-20131030/sdk/platforms/android-19/android.jar
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
最佳答案
如果您使用 Android 插件导出 Android 应用程序,该插件已经为您指定了标准配置。此配置包括基本的 -keep 选项和所有必要的 -injars 和 -outjars 选项(因此关于重复类定义的说明)。这意味着您的 proguard-project.txt 文件一开始可以是空的;它应该只包含任何特定于项目的配置。
警告说明 Foursquare 库指的是 AppEngine 库,甚至指的是 servlet 库,但您的项目中缺少后者这些库。这不是问题,因为您的应用程序可能在 Debug模式下运行良好,没有这些库,因此您可以告诉 ProGuard 忽略这些问题:
-dontwarn fi.foyt.foursquare.**
请参阅 ProGuard 手册 > 故障排除 > Warning: can't find referenced class
关于android - android应用程序中的proguard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21809964/