在Android中的eclipse中创建apk时的proguard异常

时间:2013-06-06 12:35:59

标签: android proguard

在我的应用程序中,我想启用proguard,我添加了proguard.config = proguard.cfg 在project.properties中。

我的proguard.cfg包含

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-dontwarn javax.management.**
-dontwarn java.lang.management.**
-dontwarn org.apache.log4j.**
-dontwarn org.apache.commons.logging.**
-dontwarn org.slf4j.**
-dontwarn org.json.*
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }

-keepclasseswithmembernames class * {
    native <methods>; }

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet); }

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int); }

-keepclassmembers class * extends android.app.Activity {    public void *(android.view.View); }

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String); }

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

我的控制台:

[2013-06-06 18:32:00 - Explosionfilters] Proguard returned with error code 1. See console
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.io.Buffer
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields$Field
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields$Field
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields$Field
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.Address
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.io.Buffer
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.Address
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields$Field
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.HttpRequestAdapter: can't find referenced class org.mortbay.jetty.HttpFields
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.jetty.JettyOAuthConsumer: can't find referenced class org.mortbay.jetty.client.HttpExchange
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2013-06-06 18:32:00 - Explosionfilters] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2013-06-06 18:32:00 - Explosionfilters]       You should check if you need to specify additional program jars.
[2013-06-06 18:32:00 - Explosionfilters] Warning: there were 31 unresolved references to classes or interfaces.
[2013-06-06 18:32:00 - Explosionfilters]          You may need to specify additional library jars (using '-libraryjars').
[2013-06-06 18:32:00 - Explosionfilters] java.io.IOException: Please correct the above warnings first.
[2013-06-06 18:32:00 - Explosionfilters]    at proguard.Initializer.execute(Initializer.java:321)
[2013-06-06 18:32:00 - Explosionfilters]    at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-06-06 18:32:00 - Explosionfilters]    at proguard.ProGuard.execute(ProGuard.java:86)
[2013-06-06 18:32:00 - Explosionfilters]    at proguard.ProGuard.main(ProGuard.java:492)
    please help me how to solve this issue

2 个答案:

答案 0 :(得分:1)

您没有在proguard中添加twitter4j的设置。您应该添加以下设置

-dontwarn javax.management.**
-dontwarn java.lang.management.**
-dontwarn org.apache.log4j.**
-dontwarn org.apache.commons.logging.**
-dontwarn org.slf4j.**
-dontwarn org.json.*

和此:

-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }

这将解决您的问题

答案 1 :(得分:0)

我收到同样的错误,但我的问题已经通过在我的'proguard-android.txt'文件中添加以下行来解决。

-dontwarn com.google.android.gms.**

-dontwarn org.mortbay.**
-dontwarn org.slf4j.**
-dontwarn org.apache.log4j.**
-dontwarn org.apache.commons.logging.**
-dontwarn org.apache.commons.codec.binary.**

-keep class twitter4j.** { *; }

对于Google Play服务,例如警告:com.google.android.gms.common.GooglePlayServicesUtil:找不到引用的类android.content.pm.PackageInstaller

这是解决方案!希望它也适合你!