Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProGuard keep class name but change package name

Tags:

java

proguard

want to change package name but need keep Class Name not change. any idea?

like image 700
Mike Wei Avatar asked Apr 03 '13 07:04

Mike Wei


People also ask

Can package name be same as class name?

Yes, it will work. You can have a class named abc. abc. abc.

Does ProGuard obfuscate package name?

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.

How do you keep a class in ProGuard?

-keepclassmembernames. This is the most permissive keep directive; it lets ProGuard do almost all of its work. Unused classes are removed, the remaining classes are renamed, unused members of those classes are removed, but then the remaining members keep their original names.

What is the use of ProGuard?

ProGuard is a tool to help minify, obfuscate, and optimize your code. It is not only especially useful for reducing the overall size of your Android application as well as removing unused classes and methods that contribute towards the intrinsic 64k method limit of Android applications.


1 Answers

ProGuard doesn't have a standard option to rename packages yet keep their simple class names.

You could create a ProGuard mapping file manually, with lines like:

com.example.MyClass -> a.MyClass:
com.example.MyOtherClass -> a.MyOtherClass:

You can then use the option -applymapping mapping.txt

like image 157
Eric Lafortune Avatar answered Oct 18 '22 15:10

Eric Lafortune