Exporting an Android project while using proguard on adt&sdk 20

左心房为你撑大大i 提交于 2019-12-18 08:54:21

问题


I've updated to the new adt&sdk 20, and I'm having problems with the new way Proguard is being used on Eclipse. I'm not a pro with Proguard at all, yet I've always used it and it worked quite easily. I simply edited the "project.properties" file and added there "proguard.config=proguard.cfg", and it worked.

Sadly, some changes were made that I can't find any information of how to work with them. The official website that talks about Proguard (in the Android website) still talks about the older way.

They wrote on the "project.properties" to uncomment the next line:

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

This didn't work, it gives me these errors when trying to export:

Proguard returned with error code 1. See console
java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?
at proguard.shrink.Shrinker.execute(Shrinker.java:159)
at proguard.ProGuard.shrink(ProGuard.java:275)
at proguard.ProGuard.execute(ProGuard.java:101)
at proguard.ProGuard.main(ProGuard.java:492)

Can anyone help me with this? I never had to change the proguard.cfg file before and all was quite automatic. It was very rare that i had to do such a thing.

They also added a file "proguard-project.txt" which probably replaces the proguard.cfg and "extends" from the sdk folder's file, so i wonder: will it be ok to somehow reference to the file in the project instead (and put into the file the content of the "parent" file)? If so, how do I do that?


回答1:


If it was working fine before and you haven't learnt Proguard, just change this line:

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

to this line:

 proguard.config=proguard.cfg

then you'll have your old Proguard setup back, I'd recommend updating though, it should just work unless your using some 3rd party jars? These are what is it saying is missing and you should use the -keep flag to stop Proguard from removing them when it obfuscates.




回答2:


Ok , the solution is that for some reason , I had the wrong location set for sdk.dir variable on eclipse.

So what I did is to:

  1. Go to eclipse's preferences
  2. Searched for variables
  3. And went to java->build path->classpath variables
  4. And added "sdk.dir" variable with the value of the directory of android sdk .



回答3:


create a file proguard.cfg in your project root folder and update your adt to 21 and use proguard v4.8 or 4.9 and dont forget to run Android Lint before exporting APK




回答4:


The path of default config file has been changed to

${sdk.dir}/tools/proguard/proguard-android-optimize.txt




回答5:


Using SDK 22, my solution was to copy proguard-project.txt from ${sdk.dir}/tools/proguard/ into my project workspace.

If you look at project.properties, you see that it references ${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt.

It found ${sdk.dir} just fine, but was looking for proguard-project.txt in the project directory.



来源:https://stackoverflow.com/questions/10934436/exporting-an-android-project-while-using-proguard-on-adtsdk-20

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!