无法配置Proguard提取APK

时间:2014-08-26 13:05:17

标签: android apk proguard

在我的应用上运行ProGuard时,我一直收到错误消息(远远低于)。我的应用程序中有外部库文件。

这是我的proguard-android.txt文件代码

        # This is a configuration file for ProGuard.
        # http://proguard.sourceforge.net/index.html#manual/usage.html

        -dontusemixedcaseclassnames
        -dontskipnonpubliclibraryclasses
        -verbose

        # Optimization is turned off by default. Dex does not like code run
        # through the ProGuard optimize and preverify steps (and performs some
        # of these optimizations on its own).
        -dontoptimize
        -dontpreverify
        # Note that if you want to enable optimization, you cannot just
        # include optimization flags in your own project configuration file;
        # instead you will need to point to the
        # "proguard-android-optimize.txt" file instead of this one from your
        # project.properties file.

        -keepattributes *Annotation*
        -keep public class com.google.vending.licensing.ILicensingService
        -keep public class com.android.vending.licensing.ILicensingService

        # For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
        -keepclasseswithmembernames class * {
            native <methods>;
        }

        # keep setters in Views so that animations can still work.
        # see http://proguard.sourceforge.net/manual/examples.html#beans
        -keepclassmembers public class * extends android.view.View {
           void set*(***);
           *** get*();
        }

        # We want to keep methods in Activity that could be used in the XML attribute onClick
        -keepclassmembers class * extends android.app.Activity {
           public void *(android.view.View);
        }

        # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
        -keepclassmembers enum * {
            public static **[] values();
            public static ** valueOf(java.lang.String);
        }

        -keep class * implements android.os.Parcelable {
          public static final android.os.Parcelable$Creator *;
        }

        -keepclassmembers class **.R$* {
            public static <fields>;
        }

        -keep class javax.** { *; }
        -keep class org.** { *; }
        -keep class com.squareup.** { *; }

        # The support library contains references to newer platform versions.
        # Don't warn about those in case this app is linking against an older
        # platform version.  We know about them, and they are safe.
        -dontwarn android.support.**
        -dontwarn javax.management.**
        -dontwarn java.lang.management.**
        -dontwarn org.apache.log4j.**
        -dontwarn org.apache.commons.logging.**
        -dontwarn org.slf4j.**
        -dontwarn org.json.*
        -dontwarn com.squareup.okhttp.OkHttpClient.*

Logcat错误消息:

        [2014-08-26 18:25:15 - Scootr] Proguard returned with error code 1. See console
        [2014-08-26 18:25:15 - Scootr] Note: there were 1 duplicate class definitions.
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find superclass or interface javax.servlet.ServletContextListener
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkUrlFactory
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkUrlFactory
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkUrlFactory
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkUrlFactory
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkUrlFactory
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
        [2014-08-26 18:25:15 - Scootr] Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Level
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Level
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Level
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Level
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Level
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Level
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Hierarchy
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Hierarchy
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Hierarchy
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextListener
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
        [2014-08-26 18:25:15 - Scootr] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
        [2014-08-26 18:25:15 - Scootr]       You should check if you need to specify additional program jars.
        [2014-08-26 18:25:15 - Scootr] Warning: there were 87 unresolved references to classes or interfaces.
        [2014-08-26 18:25:15 - Scootr]          You may need to specify additional library jars (using '-libraryjars').
        [2014-08-26 18:25:15 - Scootr] java.io.IOException: Please correct the above warnings first.
        [2014-08-26 18:25:15 - Scootr]  at proguard.Initializer.execute(Initializer.java:321)
        [2014-08-26 18:25:15 - Scootr]  at proguard.ProGuard.initialize(ProGuard.java:211)
        [2014-08-26 18:25:15 - Scootr]  at proguard.ProGuard.execute(ProGuard.java:86)
        [2014-08-26 18:25:15 - Scootr]  at proguard.ProGuard.main(ProGuard.java:492)

2 个答案:

答案 0 :(得分:10)

将此添加到您的proguard.cfg:

 #### -- Picasso --
 -dontwarn com.squareup.picasso.**

 #### -- OkHttp --
 -dontwarn com.squareup.okhttp.internal.**

 #### -- Apache Commons --
 -dontwarn org.apache.commons.logging.**

答案 1 :(得分:0)

您排名-dontwarn com.squareup.okhttp.OkHttpClient.*Warning: com.squareup.picasso.OkHttpDownloader无关。

您可以尝试在proguard.cfg中更改包名称

添加了: 尝试添加proguard.cfg

-dontwarn
-injars bin/classes
-injars libs
-outjars bin/classes-processed.jar

-optimizationpasses 5
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dump class_files.txt
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-allowaccessmodification
-repackageclasses ''

-keepattributes Signature

我理解proguard.cfg或proguard-project.txt(proguard-android.txt)文件。在两个文件中尝试此代码。