Error while Setting of Proguard and Exporting APK - android

I am doing first-time Proguard setting on My Android Project and Exporting My APK File but I got Following errors:
(I also not found any proguard.cfg file in my project root)
[2013-08-01 10:54:42 - SalesmanTracker] Note: there were 2 duplicate class definitions.
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.google.common.collect.MinMaxPriorityQueue: can't find referenced field 'int UNSET_EXPECTED_SIZE' in class com.google.common.collect.MinMaxPriorityQueue$Builder
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1: can't find referenced class sun.misc.Unsafe
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.salesman.activities.PlacesMapActivity: can't find referenced class com.google.android.maps.GeoPoint
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.salesman.activities.PlacesMapActivity: can't find referenced class com.google.android.maps.MapController
[2013-08-01 10:54:42 - SalesmanTracker] Warning: com.salesman.activities.PlacesMapActivity: can't find referenced class com.google.android.maps.OverlayItem
[2013-08-01 10:54:42 - SalesmanTracker] You should check if you need to specify additional program jars.
[2013-08-01 10:54:42 - SalesmanTracker] Warning: there were 9 unresolved references to classes or interfaces.
[2013-08-01 10:54:42 - SalesmanTracker] You may need to specify additional library jars (using '-libraryjars').
[2013-08-01 10:54:42 - SalesmanTracker] Warning: there were 1 unresolved references to program class members.
[2013-08-01 10:54:42 - SalesmanTracker] Your input classes appear to be inconsistent.
[2013-08-01 10:54:42 - SalesmanTracker] You may need to recompile them and try again.
[2013-08-01 10:54:42 - SalesmanTracker] Alternatively, you may have to specify the option
[2013-08-01 10:54:42 - SalesmanTracker] '-dontskipnonpubliclibraryclassmembers'.
[2013-08-01 10:54:42 - SalesmanTracker] java.io.IOException: Please correct the above warnings first.
[2013-08-01 10:54:42 - SalesmanTracker] at proguard.Initializer.execute(Initializer.java:321)
[2013-08-01 10:54:42 - SalesmanTracker] at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-08-01 10:54:42 - SalesmanTracker] at proguard.ProGuard.execute(ProGuard.java:86)
[2013-08-01 10:54:42 - SalesmanTracker] at proguard.ProGuard.main(ProGuard.java:492)
**project.properties : **
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=proguard.cfg
# Project target.
target=android-17
android.library.reference.1=..\\librarySlideMenu
android.library.reference.2=../google-play-services_lib
Please tell me about the solution to that and how to do exactly the setting of proguard.
Thanks in Advance.

Finally I Got Answer with the help of this Tutorial
I have changed following things:
In project.properties:
Uncomment or add this line:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
Now I have used Google Library so my proguard.project.txt will be like:
Here add your libraries which you have used in your project:
-libraryjars /libs/google-api-client-1.10.3-beta.jar
-libraryjars /libs/google-api-client-android2-1.10.3-beta.jar
-libraryjars /libs/google-http-client-1.10.3-beta.jar
-libraryjars /libs/google-http-client-android2-1.10.3-beta.jar
-libraryjars /libs/google-oauth-client-1.10.1-beta.jar
-libraryjars /libs/gson-2.1.jar
-libraryjars /libs/guava-11.0.1.jar
-libraryjars /libs/jackson-core-asl-1.9.4.jar
-libraryjars /libs/jsr305-1.3.9.jar
-libraryjars /libs/protobuf-java-2.2.0.jar
-libraryjars /libs/maps.jar
Add any project specific keep options here:
-keep class com.google.**
-dontwarn com.google.**
Then you can Export your APK using following steps:
Right click on project
select Export
Follow Steps
If you have any Query then you are free to ping me :)
Thank you.

Using Maven in my case, google-api-client brought guava-jdk5 as a dependency, causing similar problems.
Guava wiki page on Proguard suggests:
https://code.google.com/p/guava-libraries/wiki/UsingProGuardWithGuava
-dontwarn sun.misc.Unsafe
-dontwarn com.google.common.collect.MinMaxPriorityQueue

Add these line in your proguard-project.txt
-keep public class com.google.common.**
-keep public class * extends android.app.Activity

Related

Parse SDK Android Proguard issue

I have parse 1.5.1 in my app and everything works fine, but when I go to export to APK I get:
[2014-09-05 19:53:08 - myapp] Proguard returned with error code 1. See console
[2014-09-05 19:53:08 - myapp] Note: there were 662 duplicate class definitions.
[2014-09-05 19:53:08 - myapp] Warning: com.parse.FacebookAuthenticationProvider$1: can't find superclass or interface com.facebook.android.Facebook$ServiceListener
[2014-09-05 19:53:08 - myapp] Warning: com.parse.FacebookAuthenticationProvider$2: can't find superclass or interface com.facebook.Session$StatusCallback
[2014-09-05 19:53:08 - myapp] Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find superclass or interface com.facebook.Request$Callback
[2014-09-05 19:53:08 - myapp] Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
......
[2014-09-05 19:53:08 - myapp] at proguard.Initializer.execute(Initializer.java:321)
[2014-09-05 19:53:08 - myapp] at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-09-05 19:53:08 - myapp] at proguard.ProGuard.execute(ProGuard.java:86)
[2014-09-05 19:53:08 - myapp] at proguard.ProGuard.main(ProGuard.java:492)
In my proguard.cfg I have the following:
-keepattributes *Annotation*
-keep class com.parse.* { *; }
-libraryjars libs/Parse-1.5.1.jar
This is driving me crazy!!!
You should try also keeping the subpackages of com.parse:
-keepattributes *Annotation*
-keep class com.parse.** { *; }
You should not add -libraryjars options, since the Android build process already automatically specifies all necessary -injars, -outjars, and -libraryjars for you. It only causes warnings about duplicate classes.
Mine was fixed by adding this:
-keep class com.parse.* { *; }
-dontwarn com.parse.**
Reference: this post.

Android app export with Pro guard giving errors

I am just done with a small android app in which i need to use pro-guard for obfuscating any private keys. I have enabled pro-guard in project (IDE Eclipse) but while exporting, its giving me following errors (just pasting few of them):
[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.
Add these lines to proguard config 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
I don't know the OpenCSV library, but it looks like it was designed for standard Java. Android Java is the same programming language, but not the same runtime environment. I see references to java.awt.datatransfer.Transferable and java.beans.PropertyEditor in your error message. These classes don't exist on Android (full package list here). No amount of Proguard config is going to add them. You'll have to use a different CSV processing library, or at least, strip out and work around the parts of OpenCSV you can't use.

Proguard returned with error code 1 android parse.com

I want to apply proguard to my application, but following errors are generated.
[2014-08-26 17:53:15 - Music And Videos] Proguard returned with error code 1. See console
[2014-08-26 17:53:15 - Music And Videos] Warning: com.parse.FacebookAuthenticationProvider$1: can't find superclass or interface com.facebook.android.Facebook$ServiceListener
[2014-08-26 17:53:15 - Music And Videos] Warning: com.parse.FacebookAuthenticationProvider$2: can't find superclass or interface com.facebook.Session$StatusCallback
[2014-08-26 17:53:15 - Music And Videos] Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find superclass or interface com.facebook.Request$Callback
[2014-08-26 17:53:15 - Music And Videos] Warning: com.lnsur.kdbqq193162.MV$6: can't find referenced method 'void evaluateJavascript(java.lang.String,android.webkit.ValueCallback)' in class com.lnsur.kdbqq193162.MV
[2014-08-26 17:53:15 - Music And Videos] Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
[2014-08-26 17:53:15 - Music And Videos] Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
[2014-08-26 17:53:15 - Music And Videos] Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
Following libraries are used
My proguard-project.txt file:
-libraryjars /libs/android-support-v4.jar
-libraryjars /libs/com-lnsur-kdbqq193162.jar
-libraryjars /libs/commons-codec-1.9.jar
-libraryjars /libs/commons.io_2.0.1.jar
-libraryjars /libs/ia-sdk-lib-5.0.1.jar
-libraryjars /libs/Parse-1.5.1.jar
-libraryjars /libs/simple-4.1.11.jar
-libraryjars /libs/universal-image-loader-1.9.2-SNAPSHOT-with-sources.jar
-dontwarn com.parse.**
I don't know how to solve it, so please help me, any suggestion related to it.
Arash is right
but you need to add more
try to add
-dontwarn com.google.android.gms.**
-dontwarn com.lnsur.kdbqq193162.**
Try adding :
-dontwarn com.google.android.gms.**

gradle - proguard errors do not reflect -dontwarn

gradle 1.10 on linux on CLI
./gradlew clean
./gradlew assembleRelease
ERROR in stdout...
Note: there were 2 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 5 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Warning: there were 106 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
:proguardRelease FAILED
:proguardRelease (Thread[main,5,main]) completed. Took 4.689 secs.
FAILURE: Build failed with an exception.
I extend an oss package bundled with gradle for release builds ( added jackson.json but not from maven central ).
For some reason, proguard is throwing hundreds of 'org.joda.time... class not found' errors despite the following snips:
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
} // in 'build.gradle'
-dontwarn android.support.**
-dontwarn org.joda.time.**
-dontwarn org.codehaus.jackson.**
-dontwarn ch.boye.httpclientandroidlib.**
-dontwarn org.apache.http.**
-dontwarn android.**
-dontwarn java.**
-dontwarn com.google.sample.castcompanionlibrary.**
-dontwarn org.w3c.dom.**
-dontwarn com.google.android.gms.maps.**
#rcr adds
-libraryjars /usr/local/src/android-sdk-linux/platforms/android-19/android.jar
-libraryjars <java.home>/lib/rt.jar
-libraryjars libs/jackson-core-lgpl-1.9.2.jar
-libraryjars libs/jackson-mapper-lgpl-1.9.2.jar
-libraryjars libs/Parse-1.1.3.jar
-libraryjars libs/httpclient-1.1.jar
stdout DETAIL from './gradlew assembleRelease' below:
Initializing...
Note: the configuration refers to the unknown class 'com.google.vending.licensing.ILicensingService'
Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
Note: the configuration refers to the unknown class 'Object'
Maybe you meant the fully qualified name 'java.lang.Object'?
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.ReadableDateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.ReadableInstant
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warn
... 100s more in 'org.joda.time.**'
Note: android.support.v4.text.ICUCompatIcs: can't find dynamically referenced class libcore.icu.ICU
Note: com.google.android.gms.maps.internal.q: can't find dynamically referenced class com.google.android.gms.maps.internal.CreatorImplGmm6
Note: com.google.android.gms.maps.internal.q: can't find dynamically referenced class com.google.android.gms.maps.internal.CreatorImpl
Note: org.codehaus.jackson.map.deser.BasicDeserializerFactory: can't find dynamically referenced class java.util.ConcurrentNavigableMap
Note: org.codehaus.jackson.map.deser.BasicDeserializerFactory: can't find dynamically referenced class java.util.ConcurrentSkipListM
The -dontwarn proguard configs for 'org.joda.**' dont seem to work..
I have "-dontnote **ILicensingService" in config and that does not appear to work.
The -dontwarn config for com.google.android.gms.** not working
The -dontwarn for java.util.** not working
In what file is your "snippet" with the -dontwarn flags? It doesn't look like you're ever telling your build.gradle file about that proguard configuration.
You have:
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
But you should also have:
proguardFile 'your_proguard_config.cfg'
so that it will use both the default android configuration and your configuration.

gmailsender not working when using proguard

I am using the gmailsender to send email in my app. I followed the link below Sending Email in Android using JavaMail API without using the default/built-in app
I have however noticed that whenever I use proguard to build my APK, then the gmail sender does not work(when I install that APK). There is no error thrown, but emails are not sent. If I disable proguard and then generate the APK, then it works fine using that APK.
Can anyone please suggest what might be wrong here.
:::EDIT:::-ADDED FEW ERROR MESAGE(abridged) LINES FROM CONSOLE WHILE GENERATING APK. I COULD GET RID OF THOSE WARNING HOWEVER BY IGNORING THEM IN PROGUARD CONFIG FILE
[2013-07-09 10:00:38 - ] Proguard returned with error code 1. See console
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find superclass or interface java.awt.datatransfer.Transferable
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.datatransfer.NativeClipboard: can't find superclass or interface java.awt.datatransfer.Clipboard
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.auth.callback.NameCallback
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmCallback
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmChoiceCallback
[2013-07-09 10:00:38 - ] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans
[2013-07-09 10:00:38 - ] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2013-07-09 10:00:38 - ] You should check if you need to specify additional program jars.
[2013-07-09 10:00:38 - ] Warning: there were 247 unresolved references to classes or interfaces.
[2013-07-09 10:00:38 - ] You may need to specify additional library jars (using '-libraryjars').
[2013-07-09 10:00:38 - ] java.io.IOException: Please correct the above warnings first.
[2013-07-09 10:00:38 - ] at proguard.Initializer.execute(Initializer.java:321)
[2013-07-09 10:00:38 - ] at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-07-09 10:00:38 - ] at proguard.ProGuard.execute(ProGuard.java:86)
[2013-07-09 10:00:38 - ] at proguard.ProGuard.main(ProGuard.java:49
Finally solved the problem by updating to latest version of proguard from 4.7 to 4.9.
also added the following to the proguard config file
-dontwarn java.awt.**
-dontwarn java.beans.Beans
-dontwarn javax.security.**
-keep class javamail.** {*;}
-keep class javax.mail.** {*;}
-keep class javax.activation.** {*;}
-keep class com.sun.mail.dsn.** {*;}
-keep class com.sun.mail.handlers.** {*;}
-keep class com.sun.mail.smtp.** {*;}
-keep class com.sun.mail.util.** {*;}
-keep class mailcap.** {*;}
-keep class mimetypes.** {*;}
-keep class myjava.awt.datatransfer.** {*;}
-keep class org.apache.harmony.awt.** {*;}
-keep class org.apache.harmony.misc.** {*;}

Categories

Resources