Proguard problems with apk creation

2019-05-28 01:36发布

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.

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-05-28 02:28

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.

查看更多
不美不萌又怎样
3楼-- · 2019-05-28 02:42

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 ...

查看更多
劫难
4楼-- · 2019-05-28 02:42

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.

查看更多
登录 后发表回答