Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obfuscate an apk with Proguard through Eclipse?

I added proguard.config=proguard.cfgto my default.properties file and have a proguard.cfg file in my project root. If I now use Export as Android Application from within Eclipse I get the following Errors:

[2011-01-27 11:11:37 - Application] Warning: class [classes/com/package.Class.class] unexpectedly contains class [com/package.Class]
[2011-01-27 11:11:37 - Application] Warning: class [classes/com/package.Class2.class] unexpectedly contains class [com/package.Class2]
[2011-01-27 11:11:37 - Application] Note: there were 145 duplicate class definitions.
[2011-01-27 11:11:37 - Application] Warning: there were 146 classes in incorrectly named files.
[2011-01-27 11:11:37 - Application]          You should make sure all file names correspond to their class names.
[2011-01-27 11:11:37 - Application]          The directory hierarchies must correspond to the package hierarchies.
[2011-01-27 11:11:37 - Application]          If you don't mind the mentioned classes not being written out,
[2011-01-27 11:11:37 - Application]          you could try your luck using the '-ignorewarnings' option.
[2011-01-27 11:11:37 - Application] java.io.IOException: Please correct the above warnings first.
[2011-01-27 11:11:37 - Application]     at proguard.InputReader.execute(InputReader.java:133)
[2011-01-27 11:11:37 - Application]     at proguard.ProGuard.readInput(ProGuard.java:195)
[2011-01-27 11:11:37 - Application]     at proguard.ProGuard.execute(ProGuard.java:78)
[2011-01-27 11:11:37 - Application]     at proguard.ProGuard.main(ProGuard.java:499)

It seems that somehow my classes are saved in a classes subfolder but Proguard uses this classes subfolder as a package. Therefore the definition of the classes can not be understood by Proguard.

Is this a problem with my SDK Setup? Or are there errors in my Proguard Configuration causing this problem?

like image 875
Janusz Avatar asked Jan 27 '11 10:01

Janusz


People also ask

How do I obfuscate an APK file?

Obfuscate APK Android ProGuard tool can be used to obfuscate , shrink , and optimize the code. ProGuard renames classes, fields, and methods with semantically obscure names and removes unused code. To obfuscate we can set the minifyEnabled true in the app/build. gradle file.

Does ProGuard obfuscate code?

You can obfuscate Android code to provide security against reverse engineering. You can use the Android ProGuard tool to obfuscate, shrink, and optimize your code. Obfuscated code can be more difficult for other people to reverse engineer.

What is ProGuard obfuscation?

ProGuard is a command-line tool that reduces app size by shrinking bytecode and obfuscates the names of classes, fields and methods. It's an ideal fit for developers working with Java or Kotlin who are primarily interested in an Android optimizer.


1 Answers

I changed the proguard.cfg slightly from whatever was working for me last May and now it works:

from

-injars bin

to

-injars bin/classes

I also had to clean-up a bit--removing Junit (which wasn't used in this project) and the compatibility library (which I probably could have ignored away, but chose to ditch altogether instead).

like image 121
Private Avatar answered Sep 30 '22 08:09

Private