【问题标题】:proguard in android applicationandroid应用程序中的proguard
【发布时间】:2014-03-15 14:53:44
【问题描述】:

我在我的应用程序中使用了诸如foursquare api 和ABS 库之类的外部库。

当我在导出应用程序之前启用 proguard 时,我会在控制台中收到下面提到的错误。

Proguard 返回错误代码 1。请参阅控制台 注意:有 3686 个重复的类定义。 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPMethod 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPMethod fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPRequest 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.FetchOptions$Builder 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.FetchOptions 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPRequest 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.URLFetchServiceFactory 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.URLFetchService 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPResponse 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPResponse 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPMethod 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPMethod 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.FetchOptions$Builder 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.FetchOptions 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.URLFetchServiceFactory 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.URLFetchService 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPResponse 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPMethod 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPRequest 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.URLFetchService 警告:fi.foyt.foursquare.api.io.GAEIOHandler:找不到引用的类 com.google.appengine.api.urlfetch.HTTPResponse 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletResponse 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletRequest 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletRequest 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletResponse 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletResponse 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletRequest fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletRequest 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletResponse 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletRequest 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletResponse 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletRequest 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletResponse 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletRequest 警告:fi.foyt.foursquare.example.AuthenticationExample:找不到引用的类 javax.servlet.http.HttpServletResponse 您应该检查是否需要指定其他程序 jar。 警告:有 35 个未解析的类或接口引用。 您可能需要指定其他库 jar(使用“-libraryjars”)。 java.io.IOException: 请先更正上述警告。 在 proguard.Initializer.execute(Initializer.java:321) 在 proguard.ProGuard.initialize(ProGuard.java:211) 在 proguard.ProGuard.execute(ProGuard.java:86) 在 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 configuration apk proguard obfuscation


【解决方案1】:

如果您使用 Android 插件导出您的 Android 应用程序,该插件已经为您指定了标准配置。此配置包括基本的 -keep 选项和所有必要的 -injars 和 -outjars 选项(因此有关于重复类定义的注释)。这意味着您的 proguard-project.txt 文件一开始可以是空的;它应该只包含任何项目特定的配置。

警告说明 Foursquare 库引用了 AppEngine 库,甚至引用了 servlet 库,但您的项目中缺少这些后一个库。这不是问题,因为您的应用可能在调试模式下运行良好,没有这些库,因此您可以告诉 ProGuard 忽略这些问题:

-dontwarn fi.foyt.foursquare.**

参见 ProGuard 手册 > 疑难解答 > Warning: can't find referenced class

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-09
    • 2015-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-15
    相关资源
    最近更新 更多