今天在为app签名发布的时候,在最后生成apk文件的时候出现了错误:
Proguard returned with error code 1. See console
控制台输出信息如下:
[2012-05-14 14:58:50 - My_App] Proguard returned with error code 1. See console
[2012-05-14 14:58:50 - My_App] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-05-14 14:58:50 - My_App] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-05-14 14:58:50 - My_App] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-05-14 14:58:50 - My_App] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-05-14 14:58:50 - My_App] Warning: oauth.signpost.signature.OAuthMessageSigner: can't find referenced class org.apache.commons.codec.binary.Base64
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.CommonsLoggingLoggerFactory: can't find referenced class org.apache.commons.logging.LogFactory
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.CommonsLoggingLoggerFactory: can't find referenced class org.apache.commons.logging.LogFactory
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Level
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Level
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLoggerFactory: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.Log4JLoggerFactory: can't find referenced class org.apache.log4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLogger: can't find referenced class org.slf4j.Logger
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLoggerFactory: can't find referenced class org.slf4j.LoggerFactory
[2012-05-14 14:58:50 - My_App] Warning: twitter4j.internal.logging.SLF4JLoggerFactory: can't find referenced class org.slf4j.LoggerFactory
[2012-05-14 14:58:50 - My_App] You should check if you need to specify additional program jars.
[2012-05-14 14:58:50 - My_App] Warning: there were 33 unresolved references to classes or interfaces.
[2012-05-14 14:58:50 - My_App] You may need to specify additional library jars (using '-libraryjars').
[2012-05-14 14:58:50 - My_App] java.io.IOException: Please correct the above warnings first.
[2012-05-14 14:58:50 - My_App] at proguard.Initializer.execute(Initializer.java:321)
[2012-05-14 14:58:50 - My_App] at proguard.ProGuard.initialize(ProGuard.java:211)
[2012-05-14 14:58:50 - My_App] at proguard.ProGuard.execute(ProGuard.java:86)
[2012-05-14 14:58:50 - My_App] at proguard.ProGuard.main(ProGuard.java:492)
[2012-05-14 15:01:04 - My_App] Proguard returned with error code 1. See console
我的proguard.cfg文件内容如下:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-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
-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 *;
}
临时解决方法:直接把
proguard.config=proguard.cfg
这个配置给删除掉,就可以成功签名生成apk了
很明显不是网上所说的路径或者空格的问题,是使用proguard时有关外来jar包所带来的问题,找不到相应的class文件
所以解决方法: 根据提示,在proguard.cfg文件中添加:
-dontwarn twitter4j.internal.logging.**
-dontwarn oauth.signpost.signature.**
解决!
参考资料: