Android应用导出与Pro后卫出错

时间:2014-09-13 09:57:27

标签: android obfuscation proguard

我刚刚完成了一个小型Android应用程序,我需要使用pro-guard来混淆任何私钥。我在项目(IDE Eclipse)中启用了pro-guard,但在导出时,它给了我以下错误(只是粘贴了一些错误):

[2014-09-13 15:12:05 - ABC] Proguard returned with error code 1. See console
[2014-09-13 15:12:05 - ABC] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't      find superclass or interface java.awt.datatransfer. Transferable
[2014-09-13 15:12:05 - ABC] Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyEditor
[2014-09-13 15:12:05 - ABC] Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyEditor
[2014-09-13 15:12:05 - ABC] Warning: au.com.bytecode.opencsv.bean.MappingStrategy: can't find referenced class java.beans.IntrospectionException
[2014-09-13 15:12:05 - ABC] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslException
[2014-09-13 15:12:05 - ABC] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans
[2014-09-13 15:12:05 - ABC] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2014-09-13 15:12:05 - ABC] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.DataFlavor
[2014-09-13 15:12:05 - ABC] Warning: org.apache.harmony.awt.datatransfer.DataSnapshot: can't find referenced class java.awt.datatransfer.DataFlavor
[2014-09-13 15:12:05 - ABC] Warning: org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.Point
[2014-09-13 15:12:05 - Remembrall] Warning: org.apache.harmony.awt.datatransfer.TextFlavor: can't find referenced class java.awt.datatransfer.DataFlavor
[2014-09-13 15:12:05 - Remembrall]       You should check if you need to specify additional program jars.
[2014-09-13 15:12:05 - Remembrall] Warning: there were 286 unresolved references to classes or interfaces.
[2014-09-13 15:12:05 - Remembrall]          You may need to specify additional library jars (using '-libraryjars').
[2014-09-13 15:12:05 - Remembrall] Error: Please correct the above warnings first.
[2014-09-13 15:12:06 - Remembrall] WARNING: Found both android-support-v4 and android-support-v13 in the dependency list.
[2014-09-13 15:12:06 - Remembrall] Because v13 includes v4, using only v13.
[2014-09-13 15:12:07 - Remembrall] WARNING: Found both android-support-v4 and android-support-v13 in the dependency list.
[2014-09-13 15:12:07 - Remembrall] Because v13 includes v4, using only v13.
[2014-09-13 15:12:18 - Remembrall] WARNING: Found both android-support-v4 and android-support-v13 in the dependency list.
[2014-09-13 15:12:18 - Remembrall] Because v13 includes v4, using only v13.
[2014-09-13 15:12:18 - Remembrall] WARNING: Found both android-support-v4 and android-support-v13 in the dependency list.
[2014-09-13 15:12:18 - Remembrall] Because v13 includes v4, using only v13.

2 个答案:

答案 0 :(得分:1)

将这些行添加到proguard配置文件(proguard-android.txt)

-keep class android.support.v4.** { *; }   
-dontwarn android.support.v4.**
-dontwarn javax.activation.**
-dontwarn javax.security.**
-dontwarn java.awt.**
-libraryjars <java.home>/lib/rt.jar
-keep class javax.** {*;}
-keep class com.sun.** {*;}
-keep class myjava.** {*;}
-keep class org.apache.harmony.** {*;}
-keep public class Mail {*;}        
-dontshrink

答案 1 :(得分:1)

我不了解OpenCSV库,但它看起来像是为标准Java而设计的。 Android Java是相同的编程语言,但不是相同的运行时环境。我在您的错误消息中看到对java.awt.datatransfer.Transferablejava.beans.PropertyEditor的引用。这些课程不存在于Android(full package list here)上。没有任何数量的Proguard配置会添加它们。您必须使用不同的CSV处理库,或至少剥离并解决您无法使用的OpenCSV部分。