I am developing an android library and I want to hide it's code.
I am using other library, and for some of them, when trying to access their code with Android Studio, you only get the list of methods of the class and "/* compiled code*/" inside.
I am using pro-guard, but i can still access the source code of my library. Even if the methods and members names have been modified, the code is still readable and it is possible to read every hard coded strings.
How do I hide my code the same way those libraries do ?
Android Studio replaces the actual code with something like /* compiled code */
only if you don't have the actual source code for the library and the decompiler isn't activated. But it's trivial to either attach the source code or to install a decompiler.
You can display the bytecode of any class using javap
. See Is it possible to view bytecode of Class file? for details.
Back to your original question: No, it's not possible to actually hide your code because the code is required to actually execute it. And if the code is there you can see the bytecode and decompile it. The best option you have is to obfuscate the code using Proguard which won't get you very far either regarding hiding your code. See How to avoid reverse engineering of an APK file? and Android ProGuard how to hide/obfuscate source code of exported library.