android - 试图让 proguard 工作,但它总是失败

标签 android proguard

请不要将其作为重复项关闭!

我已经尝试升级到 proguard 4.11

我已经尝试添加我使用的库和我使用的库(这有意义吗:O)

我尝试添加 -keep class com.google.** 并保留其他类

我试过-dontwarn fi.foyt.*

相关文件如下:

proguard-project.txt

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:
-libraryjars libs/android-support-v4.jar
-libraryjars libs/crashlytics.jar
-libraryjars libs/libGoogleAnalyticsServices.jar
-libraryjars other/easyfoursquare4android/easyFoursquare4Android/bin/easyfousquareactivity.jar
-libraryjars other/foursquare-android-oauth/foursquare-oauth-library/bin/foursquare-oauth-library.jar
-libraryjars other/easyfoursquare4android/easyFoursquare4Android/libs/foursquare-api-1.0.2.jar
-libraryjars other/easyfoursquare4android/easyFoursquare4Android/libs/gson-2.2.1.jar
#-keep class com.google.** { *; }
#-keep class fi.foyt.foursquare.** { *; }
#-keep class javax.** { *; }
#-keep class org.** { *; }
#-dontwarn fi.foyt.*
#-keep class fi.foyt.**
#-keep public class android.content.Context
#-keep public interface fi.foyt.**
#-keep public class fi.foyt.**

#-dontwarn android.support.v4.**
#-keep class java.lang.reflect.**

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

项目.properties

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
android.library.reference.1=other/foursquare-android-oauth/foursquare-oauth-library
android.library.reference.2=other/easyfoursquare4android/easyFoursquare4Android

相关控制台日志:(click me for full log)

[2014-03-26 01:25:30 - MyAppName] Note: duplicate definition of library class [com.google.gson.JsonSerializationContext]
[2014-03-26 01:25:30 - MyAppName] Reading library jar [/Users/shereef/android-sdks/platforms/android-19/android.jar]
[2014-03-26 01:25:31 - MyAppName] Note: there were 1486 duplicate class definitions.
[2014-03-26 01:25:31 - MyAppName] Initializing...
[2014-03-26 01:25:31 - MyAppName]       (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
[2014-03-26 01:25:31 - MyAppName] Note: the configuration refers to the unknown class 'com.google.vending.licensing.ILicensingService'
[2014-03-26 01:25:31 - MyAppName] Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions$Builder
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions$Builder
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Note: android.support.v4.text.ICUCompatIcs: can't find dynamically referenced class libcore.icu.ICU
[2014-03-26 01:25:32 - MyAppName] Note: com.google.gson.internal.UnsafeAllocator: can't find dynamically referenced class sun.misc.Unsafe
[2014-03-26 01:25:32 - MyAppName] Note: there were 2 references to unknown classes.
[2014-03-26 01:25:32 - MyAppName]       You should check your configuration for typos.
[2014-03-26 01:25:32 - MyAppName]       (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
[2014-03-26 01:25:32 - MyAppName] Warning: there were 35 unresolved references to classes or interfaces.
[2014-03-26 01:25:32 - MyAppName] Note: there were 2 unresolved dynamic references to classes or interfaces.
[2014-03-26 01:25:32 - MyAppName]       You should check if you need to specify additional program jars.
[2014-03-26 01:25:32 - MyAppName]       (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
[2014-03-26 01:25:32 - MyAppName]          You may need to add missing library jars or update their versions.
[2014-03-26 01:25:32 - MyAppName]          If your code works fine without the missing classes, you can suppress
[2014-03-26 01:25:32 - MyAppName]          the warnings with '-dontwarn' options.
[2014-03-26 01:25:32 - MyAppName]          (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
[2014-03-26 01:25:32 - MyAppName] java.io.IOException: Please correct the above warnings first.
[2014-03-26 01:25:32 - MyAppName]   at proguard.Initializer.execute(Initializer.java:369)
[2014-03-26 01:25:32 - MyAppName]   at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-03-26 01:25:32 - MyAppName]   at proguard.ProGuard.execute(ProGuard.java:86)
[2014-03-26 01:25:32 - MyAppName]   at proguard.ProGuard.main(ProGuard.java:483)
[2014-03-26 01:25:32 - MyAppName] Proguard returned with error code 1. See console
[2014-03-26 01:25:32 - MyAppName] Note: there were 1486 duplicate class definitions.
[2014-03-26 01:25:32 - MyAppName]       (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions$Builder
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions$Builder
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest
[2014-03-26 01:25:32 - MyAppName] Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse
[2014-03-26 01:25:32 - MyAppName] Warning: there were 35 unresolved references to classes or interfaces.
[2014-03-26 01:25:32 - MyAppName]          You may need to add missing library jars or update their versions.
[2014-03-26 01:25:32 - MyAppName]          If your code works fine without the missing classes, you can suppress
[2014-03-26 01:25:32 - MyAppName]          the warnings with '-dontwarn' options.
[2014-03-26 01:25:32 - MyAppName]          (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
[2014-03-26 01:25:32 - MyAppName] java.io.IOException: Please correct the above warnings first.
[2014-03-26 01:25:32 - MyAppName]   at proguard.Initializer.execute(Initializer.java:369)
[2014-03-26 01:25:32 - MyAppName]   at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-03-26 01:25:32 - MyAppName]   at proguard.ProGuard.execute(ProGuard.java:86)
[2014-03-26 01:25:32 - MyAppName]   at proguard.ProGuard.main(ProGuard.java:483)
[2014-03-26 01:25:32 - EasyFousquareActivity] Using default Build Tools revision 19.0.3

检查我的 proguard-project.txt 我已经评论了我尝试过但没有意义的行

最佳答案

您的库中缺少某些类,例如 com.google.appengine.api.urlfetch.HTTPMethod。显然,您的应用程序无论如何都不会使用它们,因此您可以告诉 ProGuard 它没问题。例如:

-dontwarn fi.foyt.foursquare.**

-dontnote libcore.icu.ICU
-dontnote sun.misc.Unsafe

请参阅 ProGuard 手册 > 故障排除 > Warning: can't find referenced class .

此外,您不应在配置文件中指定-injars-libraryjars 选项。 Ant/Eclipse/Gradle 构建过程已经根据你的项目的内容。

请参阅 ProGuard 手册 > 故障排除 > Note: duplicate definition of program/library class

关于android - 试图让 proguard 工作,但它总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22648568/

相关文章:

Android ProGuard 混淆库 : keep class not working

android - 任务 ':app:transformClassesWithAndroidGradleClassShrinkerForDebug' 执行失败

android - ICS 是否支持 android.app.Fragment?

Android 浏览历史仅遗漏了一些网站

android - native react - 获取构建工具文件时出错

java - Proguard 和 apache 遗产

xamarin - ProGuard:添加 ModernHTTPClient 后, "java.exe"退出并显示代码 1

android - Retrofit2 proguard 删除参数

android - Gradle 构建错误 : cannot access ParametersAreNonnullByDefault class file when using Realm

android - 你知道这个改造错误吗?