Failed to fix Android Proguard error with error 1

When I try to use proguard in my android app, just adding

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt 

to the project.properties file, the export of the APK ends with the message Proguard Returned with error code 1

This is my project.properties file

 target=android-18 android.library.reference.1=../LVL proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt 

This is the error stack:

  Proguard returned with error code 1. See console [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find superclass or interface java.awt.datatransfer.Transferable [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.NativeClipboard: can't find superclass or interface java.awt.datatransfer.Clipboard [2013-08-28 18:27:13 - MyApp] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl [2013-08-28 18:27:13 - MyApp] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl [2013-08-28 18:27:13 - MyApp] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient [2013-08-28 18:27:13 - MyApp] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient [2013-08-28 18:27:13 - MyApp] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient [2013-08-28 18:27:13 - MyApp] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient [2013-08-28 18:27:13 - MyApp] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmChoiceCallback [2013-08-28 18:27:13 - MyApp] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans [2013-08-28 18:27:13 - MyApp] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProvider: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProvider: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProvider: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProvider: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.Transferable [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.UnsupportedFlavorException [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataSnapshot: can't find referenced class java.awt.datatransfer.SystemFlavorMap [2013-08-28 18:27:13 - MyApp] Warning: org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor [2013-08-28 18:27:13 - MyApp] Warning: there were 247 unresolved references to classes or interfaces. [2013-08-28 18:27:13 - MyApp] You may need to specify additional library jars (using '-libraryjars'). [2013-08-28 18:27:13 - MyApp] java.io.IOException: Please correct the above warnings first. [2013-08-28 18:27:13 - MyApp] at proguard.Initializer.execute(Initializer.java:321) [2013-08-28 18:27:13 - MyApp] at proguard.ProGuard.initialize(ProGuard.java:211) [2013-08-28 18:27:13 - MyApp] at proguard.ProGuard.execute(ProGuard.java:86) [2013-08-28 18:27:13 - MyApp] at proguard.ProGuard.main(ProGuard.java:492) 
+7
android proguard
source share
6 answers

Add these lines to the proguard configuration file (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 

See Troubleshoot Proguard

Please note that if you use

 proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt 

Your configuration file is not proguard-android.txt in the root of your project, but a common proguard configuration file in the android sdk folder. If you want to use proguard-android.txt at the root of your project, you should use

 proguard.config=proguard-project.txt 

in the project.properties file.

+15
source share

CFR. ProGuard Guide> Troubleshooting> Warning: Cannot Find Reference Class

There are no AWT classes in the Android SDK. ProGuard sees some classes that depend on them and warn about them, as a compiler would do. Since classes are apparently never used, you can tell ProGuard to ignore it:

 -dontwarn java.awt.** 

ProGuard will continue to process the code. You should not add any -libraryjars options.

+3
source share

in the error stack, below, pay attention not to "indicate additional banks ..."

Review the proguard configuration to include the android, which includes all the mentioned missing packages, such as "javax" and "awt" enter code here

try adding something like the following to your proguard.cfg ...

 -libraryjars /usr/local/src/android-sdk-linux/platforms/android-18/android.jar -libraryjars <java.home>/lib/rt.jar 
+1
source share

I had the same problem in eclipse. I could solve this by adding

-ignorewarnings

in the progaurd-project.txt file

+1
source share

update your progaurd to the latest version 4.10 at this link

http://sourceforge.net/projects/proguard/files/proguard/4.10/

unzip the file and replace its contents in the sdk android directory (progaud folder in the tools directory)

[path to android sdk] \ Android \ android-sdk \ tools \ proguard

then try again, you may need to restart eclipse.

0
source share

I successfully ignored invalid package errors in eclipse in the following procedure:

right-click on the project> Properties> link to the elevator link> in the search bar "invalid"> and select the identifier = InvalidPackage> and in the lower right part change the severity level to ignore.

enter image description here

Please note that this is a dirty workaround (I could not get proguard to ignore so ...)

Good luck

0
source share

All Articles