【发布时间】:2014-07-07 01:15:46
【问题描述】:
我创建了一个必须提供给第三方应用程序的 android 库项目,我有两个要求,
1)将库项目转换成jar文件(或),
2)对库项目中的源代码进行混淆处理。
基本上我不想让第 3 方应用程序开发人员获取我的源代码。
请帮忙!提前致谢!
【问题讨论】:
标签: java android jar obfuscation android-support-library
我创建了一个必须提供给第三方应用程序的 android 库项目,我有两个要求,
1)将库项目转换成jar文件(或),
2)对库项目中的源代码进行混淆处理。
基本上我不想让第 3 方应用程序开发人员获取我的源代码。
请帮忙!提前致谢!
【问题讨论】:
标签: java android jar obfuscation android-support-library
ProGuard-Application 可让您缩小和混淆代码。它来自 Android 开发人员,因此您可以假设使用它是安全的。
【讨论】:
这是你能得到的最接近的:
1: Create a regular Android library project, and get it working.
2: Copy that Android library project into another directory.
3: Create a JAR from the compiled Java classes from the original Android library project, and put that JAR in the libs/ directory of the copy you made in Step #2. You should be able to run ProGuard on this JAR manually, though I haven't tried that.
4: Remove everything inside the src/ directory of the copied library project, leaving behind and empty src/ directory.
5: ZIP up or otherwise distribute the copied Android library project.
【讨论】:
这是你需要做的:
创建您的库项目。编写一个测试您的库的测试应用程序。构建您的库项目。您可以通过 Eclipse 使用 ant/maven。大多数库现在需要 gradle 支持,因为应用程序现在使用 Android Studio。通过转到 Project -> Properties -> Android 并选中 Is Library 复选框,将您的项目标记为库。检查此链接:http://developer.android.com/tools/projects/projects-eclipse.html。
如果您不希望第三方应用程序开发人员看到您的源文件,则需要启用 proguard。这个工具会缩小、混淆你的代码。使用你的库的应用程序对哪些代码需要混淆有很大的控制权。例如,应用程序可以通过在其 proguard 配置文件中指定 -keep 选项来决定它希望所有以 com.blah.blah* 开头的包不被混淆。这将防止某些代码部分被混淆。您应该允许库的默认混淆,除非您决定使用无法通过混淆(如注释或反射)起作用的组件。
通过启用 proguard,第三方开发人员将无法在对您的 apk 进行逆向工程时访问您的源代码。明智地使用!
【讨论】: