I am developing an Android app that sends e-mails using the GMail API. I have used the example code at Android Quickstart and Sending Email and everything works fine when I debug the app.
The problem arises when I build the release version with minifyEnabled=true
. In that case, the call to service.users().messages().send(userId, message).execute();
goes into error with IOException
. The message of the exception is "404 Not Found".
The Proguard file includes all the -keep class
and -dontwarn
that I have found in other posts:
-dontwarn com.google.**
-dontwarn java.awt.**
-dontwarn javax.security.**
-dontwarn java.beans.**
-keep class com.google.**
-keep public class Mail {*;}
-keep class com.sun.activation.** {*;}
-keep class com.sun.activation.registries {*;}
-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.** {*;}
I don't think it is a problem of credentials as e-mails are sent if I sign the app with minifyEnabled=false
. I also tested the release version of the app on the emulator, setting minifyEnabled=true
and debuggable=true
. In this case e-mails are sent but the APK is larger when it is debuggable so I think that something fundamental is retained ase.
Dependecies in the gradle file are the following
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-gmail:v1-rev47-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile 'org.achartengine:achartengine:1.2.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.12.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'pub.devrel:easypermissions:0.1.5'
}
I am not sure about exclude group: 'org.apache.httpcomponents'
but removing it does not solve the problem.