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.** {*;}
Related
I try to use Proguard in my app. I wrote this code in proguard.cfg file:
-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 Mp4ParserWrapper.** { *; }
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
When export app get can't find referenced class error .I search on the internet and add this line -keep public class Mp4ParserWrapper. { *; }** to proguard file but don't solve problem .
Console :
[2015-10-16 17:29:09 - nabege] Proguard returned with error code 1. See console
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class javax.imageio.ImageIO
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class javax.imageio.ImageIO
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class java.awt.image.BufferedImage
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class java.awt.image.BufferedImage
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class java.awt.image.BufferedImage
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class java.awt.image.BufferedImage
[2015-10-16 17:29:09 - nabege] You should check if you need to specify additional program jars.
[2015-10-16 17:29:09 - nabege] Warning: there were 6 unresolved references to classes or interfaces.
[2015-10-16 17:29:09 - nabege] You may need to specify additional library jars (using '-libraryjars').
[2015-10-16 17:29:09 - nabege] java.io.IOException: Please correct the above warnings first.
[2015-10-16 17:29:09 - nabege] at proguard.Initializer.execute(Initializer.java:321)
[2015-10-16 17:29:09 - nabege] at proguard.ProGuard.initialize(ProGuard.java:211)
[2015-10-16 17:29:09 - nabege] at proguard.ProGuard.execute(ProGuard.java:86)
[2015-10-16 17:29:09 - nabege] at proguard.ProGuard.main(ProGuard.java:492)
[2015-10-16 17:29:09 - nabege] Picked up _JAVA_OPTIONS: -Xms256m -Xmx512m
You need to add -dontwarn com.googlecode.mp4parser.**
I need to generate a signed APK for Play Store. ( using Android Studio )
If I do that without proguard ( minifyEnabled false in build.gradle ) all works fine!
If I activate it with default parameters :
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
I receive these warnings
:app:proguardRelease
Warning: com.android.volley.error.VolleyErrorHelper$1: can't find superclass or interface com.google.gson.reflect.TypeToken
Warning: com.android.volley.error.VolleyErrorHelper: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.error.VolleyErrorHelper: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.error.VolleyErrorHelper: can't find referenced method 'java.lang.reflect.Type getType()' in program class com.android.volley.error.VolleyErrorHelper$1
Warning: com.android.volley.error.VolleyErrorHelper: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.error.VolleyErrorHelper$1: can't find referenced class com.google.gson.reflect.TypeToken
Warning: com.android.volley.error.VolleyErrorHelper$1: can't find referenced class com.google.gson.reflect.TypeToken
Warning: com.android.volley.error.VolleyErrorHelper$1: can't find referenced class com.google.gson.reflect.TypeToken
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.JsonSyntaxException
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.JsonSyntaxException
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.Gson
Warning: com.android.volley.request.GsonRequest: can't find referenced class com.google.gson.JsonSyntaxException
Warning: com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getContentLengthLong()' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl
Warning: com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getHeaderFieldLong(java.lang.String,long)' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl
Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: there were 28 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 3 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Exception while processing task
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:473)
at proguard.ProGuard.initialize(ProGuard.java:233)
at proguard.ProGuard.execute(ProGuard.java:98)
at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:137)
at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:113)
at com.android.builder.tasks.Job.runTask(Job.java:48)
at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227)
at java.lang.Thread.run(Thread.java:745)
:app:dexRelease UP-TO-DATE
:app:validateExternalOverrideSigning
:app:packageRelease
And the build process stop with this message :
Error:Execution failed for task ':app:packageRelease'.
> Unable to compute hash of ...\app\build\intermediates\classes-proguard\release\classes.jar
After several tentatives I've found a way to remove the warnings with this lines in my "proguard-rules.pro" :
-dontwarn com.android.volley.**
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
But the build process still goes in error!
Anyone have a workaround for this problem?
Thanks!
Davide
After several attemps ... here the solution :
First configure the dontwarn as suggested by Raymond ( maybe this is not necessary but i left it ) :
-dontwarn com.google.gson.**
-dontwarn java.nio.file.**
-dontwarn org.codehaus.mojo.animal_sniffer.**
-dontwarn com.squareup.okhttp.internal.huc.**
-dontwarn com.android.volley.error.**
Then configure Proguard to skip my library :
-keep class com.android.volley.error.** { *; }
-keep class com.squareup.okhttp.internal.huc.** { *; }
-keep class okio.** { *; }
Ather that the compilation was ok but on runtime the application crashed.
So, to avoid this problem, i've added these lines :
-keep class android.support.design.widget.** { *; }
-keep interface android.support.design.widget.** { *; }
-dontwarn android.support.design.**
based on some info found from this thread :
java.lang.RuntimeException: Could not inflate Behavior subclass
With this settings i'm able to generate a signed APK of my app.
You have to apply dontwarn to the referenced class instead.
For example:
-dontwarn com.google.gson.**
-dontwarn java.nio.file.**
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.
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.
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.**