2

OK This is driving me nuts since a day. I am mainly an iOS guy so i dont know much about Proguard and stuff. I have made an Android app which includes both dropbox and Google Drive API. The app is working great if i deploy it on a phone thru Eclipse but I am getting a nasty error on Console when i try to export the app for apk file generation. My project.properties files was like so...

# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt:proguard-google-api-client.txt

# Project target.
target=android-17
android.library=false

And the error dialog was this... PROJECT_FOLDER_NAME/proguard-project.txt does not exist or is not a regular file

So i edited my project.properties and removed proguard-project.txt part.

Now while creating apk i get these errors on console...

[2013-05-15 18:48:28 - BackMyAppUp] Proguard returned with error code 1. See console
[2013-05-15 18:48:28 - BackMyAppUp] Note: there were 367 duplicate class definitions.
[2013-05-15 18:48:28 - BackMyAppUp] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find superclass or interface javax.servlet.ServletContextListener
[2013-05-15 18:48:28 - BackMyAppUp] Warning: org.apache.http.entity.mime.FormBodyPart: can't find superclass or interface org.apache.james.mime4j.message.BodyPart
[2013-05-15 18:48:28 - BackMyAppUp] Warning: org.apache.http.entity.mime.HttpMultipart: can't find superclass or interface org.apache.james.mime4j.message.Multipart
[2013-05-15 18:48:28 - BackMyAppUp] Warning: org.apache.http.entity.mime.MinimalField: can't find superclass or interface org.apache.james.mime4j.parser.Field
[2013-05-15 18:48:28 - BackMyAppUp] Warning: org.apache.http.entity.mime.content.AbstractContentBody: can't find superclass or interface org.apache.james.mime4j.message.SingleBody
[2013-05-15 18:48:28 - BackMyAppUp] Warning: org.apache.http.entity.mime.content.ContentBody: can't find superclass or interface org.apache.james.mime4j.message.Body
[2013-05-15 18:48:28 - BackMyAppUp] Warning: org.apache.http.entity.mime.content.ContentBody: can't find superclass or interface org.apache.james.mime4j.descriptor.ContentDescriptor
[2013-05-15 18:48:28 - BackMyAppUp] Warning: library class android.net.http.AndroidHttpClient extends or implements program class org.apache.http.client.HttpClient
[2013-05-15 18:48:28 - BackMyAppUp] Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced class com.google.android.gms.R
[2013-05-15 18:48:28 - BackMyAppUp] Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced class com.google.android.gms.R$string
[2013-05-15 18:48:28 - BackMyAppUp] Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced class com.google.android.gms.R$string
[2013-05-15 18:48:28 - BackMyAppUp] Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced class com.google.android.gms.R$string

and some 300 similar lines.

If i use the apk generated from bin folder, the google drive feature doesn't work in the phone, but it works if i deploy thru Ecipse. Please help me out.

Akash Malhotra
  • 1,106
  • 1
  • 17
  • 30
  • Similar: http://stackoverflow.com/questions/18646899/proguard-cant-find-referenced-class-com-google-android-gms-r/ – trante Jun 08 '14 at 18:57

3 Answers3

4

FWIW, after upgrading to ADT 22 I had over 800 similar errors with a Proguard configuration that was previously working fine, The app also crashed on a device with ClassDefNotFound errors when built without Proguard..

The solution in the end was to tick "Android Private Libraries" on the Order and Export tab of the build path editor for my main project and all of its library projects.

user2066471
  • 41
  • 1
  • 2
  • its already ticked, I added some -dontwarn stuff and now the apk is created but the app crashed at the Google Drive upload part. – Akash Malhotra May 18 '13 at 08:02
2

Either you want to use Proguard (optimization, obfuscation, ...) or you don't.

If you dont want, just comment (with a #) the part pointing to your proguard configuration in your project.properties :

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt:proguard-google-api-client.txt

If you want to, the solution is to keep the line as it, and create the folowing files : proguard-project.txt and proguard-google-api-client.txt

For the proguard-google-api-client.txt, you can find an exemple here : https://google-api-java-client.googlecode.com/hg/google-api-client-assembly/proguard-google-api-client.txt

For the proguard-project.txt, it will depends on what errors you get after filing the other one. You might need to add several :

-libjars <path_to_a_jar_used_in_app>

and some other -dontwarn, depending on warnings you get ...

Passeur
  • 71
  • 1
  • 6
  • If i dont use proguard by commenting in the project txt, the dropbox part works fine but not the Google drive part. – Akash Malhotra May 17 '13 at 08:02
  • Ok, so, another wild guess. try in your project.properties the following line : proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-google-api-client.txt And in proguard-google-api-client.txt (create it if you need to), copy the proguard configuration that I've gave in the previous answer. And please specify, if it is not working, if it is not working during building, executing on the emulator, or on your physical phone. – Passeur May 17 '13 at 11:26
  • Just a brief note: Your `-libjars` hint helped me alot to solve my problem but the correct command is `-libraryjars`. Maybe this helps other to avoid a few minutes of confusion and searching :-) – Andrei Herford Aug 29 '14 at 07:48
0

Well this feels kinda stupid, for 3 days I messed around with proguard but the problem was that I used the debug keystore SHA1 key in the release apk, hence the Google drive app crash, I used the correct SHA1 key in Google API console to solve it.

Akash Malhotra
  • 1,106
  • 1
  • 17
  • 30