简体   繁体   English

将android库项目转换为jar文件

[英]Converting android library project to jar file

I have a create an android library project which has to be given to a 3rd party application,I have two requirements, 我有一个创建的android库项目,必须将其提供给第三方应用程序,我有两个要求,

1)convert the library project into a jar file (or), 1)将库项目转换为jar文件(或),

2)Make the source code in the library project obfuscated. 2)使库项目中的源代码变得模糊。

Basically i dont want to 3rd party application developer to get my source code. 基本上,我不想让第三方应用程序开发人员获取我的源代码。

Please help! 请帮忙! thanks in advance! 提前致谢!

The ProGuard -Application lets you shrink and obfuscate your code. ProGuard -Application使您可以收缩和混淆代码。 It is from the Android developers, so you can assume it is safe to use it. 它来自Android开发人员,因此您可以假设使用它是安全的。

This is the closest that you can get: 这是您可以获得的最接近的:

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.

This is what you need to do: 这是您需要做的:

  1. Create your library project. 创建您的库项目。 Write a test application that tests your library. 编写测试您的库的测试应用程序。 Build your library project. 构建您的图书馆项目。 You could use ant/maven through eclipse. 您可以通过Eclipse使用ant / maven。 Most libraries now need gradle support because applications are now using Android Studio. 现在,大多数库都需要gradle支持,因为应用程序现在正在使用Android Studio。 Mark your project as a library by going to Project -> Properties -> Android and select the Is Library checkbox. 转到项目->属性-> Android,将您的项目标记为一个库,然后选择是库复选框。 Check this link: http://developer.android.com/tools/projects/projects-eclipse.html . 检查此链接: http : //developer.android.com/tools/projects/projects-eclipse.html

  2. If you don't want a 3rd party app developer to see your source files, you need to enable proguard. 如果您不希望第三方应用程序开发人员查看您的源文件,则需要启用proguard。 This tool shrinks, obfuscates your code. 该工具会缩小,使您的代码变得模糊。 The application that uses your library has a lot of control over what code needs obfuscation. 使用您的库的应用程序可以控制哪些代码需要混淆。 For example, an application can decide that it wants all packages starting with com.blah.blah* to not be obfuscated by specifying the -keep option in its proguard config file. 例如,应用程序可以通过在其proguard配置文件中指定-keep选项来决定不希望混淆以com.blah.blah *开头的所有软件包。 This will prevent certain sections of code from getting obfuscated. 这将防止混淆代码的某些部分。 You should allow default obfuscation for libraries unless you decide to use components which don't function with obfuscation (like annotations or reflections). 除非您决定使用对混淆不起作用的组件(例如注释或反射),否则应允许对库进行默认混淆。

By enabling proguard, a third party developer will not get access to your source on reverse-engineering your apk. 通过启用proguard,第三方开发人员将无法通过对apk进行反向工程来访问您的源。 Use wisely! 明智地使用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM