将android库项目转换为jar文件

时间:2014-05-19 07:04:59

标签: java android jar obfuscation android-support-library

我有一个创建一个Android库项目,必须提供给第三方应用程序,我有两个要求,

1)将库项目转换为jar文件(或),

2)使库项目中的源代码混淆。

基本上我不想让第三方应用程序开发人员获取我的源代码。

请帮忙!提前谢谢!

3 个答案:

答案 0 :(得分:0)

ProGuard - 应用程序可让您缩小和混淆代码。它来自Android开发人员,因此您可以认为使用它是安全的。

答案 1 :(得分:0)

这是你最接近的:

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.

答案 2 :(得分:0)

这是你需要做的:

  1. 创建您的图书馆项目。编写测试库的测试应用程序。构建您的库项目。你可以通过eclipse使用ant / maven。大多数库现在都需要gradle支持,因为应用程序现在正在使用Android Studio。通过转到Project - >将您的项目标记为库。属性 - > Android并选择Is Library复选框。请检查此链接:http://developer.android.com/tools/projects/projects-eclipse.html

  2. 如果您不希望第三方应用开​​发者查​​看您的源文件,则需要启用proguard。此工具缩小,模糊了您的代码。使用您的库的应用程序可以很好地控制代码需要混淆的代码。例如,应用程序可以通过在其proguard配置文件中指定-keep选项来决定是否希望所有以com.blah.blah *开头的包不被混淆。这将阻止某些代码段被混淆。您应该允许对库进行默认模糊处理,除非您决定使用不具有模糊处理功能的组件(如注释或反射)。

  3. 通过启用proguard,第三方开发人员无法通过对apk进行逆向工程来访问您的源代码。明智地使用!