隐藏库源代码 [英] Hide a library source code

查看:59
本文介绍了隐藏库源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个android库,我想隐藏它的代码. 我正在使用其他库,对于其中一些库,当尝试使用Android Studio访问其代码时,您只会获得该类的方法列表以及内部的"/ *编译代码* /". 我正在使用pro-guard,但是我仍然可以访问我的库的源代码.即使方法和成员名称已被修改,代码仍然可读,并且可以读取每个硬编码的字符串.

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才会使用类似/* compiled code */的代码替换实际代码.但是,要么附加源代码,要么安装反编译器都是很简单的.

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.

您可以使用javap显示任何类的字节码.请参见是否可以查看Class文件的字节码?了解详情.

You can display the bytecode of any class using javap. See Is it possible to view bytecode of Class file? for details.

回到您的原始问题:不,实际上无法隐藏您的代码,因为实际执行代码是必需的.并且如果有代码,则可以看到字节码并对其进行反编译.您最好的选择是使用Proguard对代码进行混淆,这对于隐藏代码也不会帮助您太多.请参阅如何避免APK文件的反向工程? Android ProGuard如何隐藏/混淆导出的库的源代码.

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.

这篇关于隐藏库源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆