Hide a library source code

旧巷老猫 提交于 2019-11-27 06:22:39

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/42133700/hide-a-library-source-code

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