0

I have a create an android library project which has to be given to a 3rd party application,I have two requirements,

1)convert the library project into a jar file (or),

2)Make the source code in the library project obfuscated.

Basically i dont want to 3rd party application developer to get my source code.

Please help! thanks in advance!

3 Answers3

0

The ProGuard-Application lets you shrink and obfuscate your code. It is from the Android developers, so you can assume it is safe to use it.

Manuel Allenspach
  • 12,467
  • 14
  • 54
  • 76
0

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.
Basbous
  • 3,927
  • 4
  • 34
  • 62
  • Hi, thanks for replying. Can you kindly explain me the steps to be performed for step #3 ?? – user3505559 May 19 '14 at 07:20
  • Once you have the library project in a .jar file, you can run Proguard from command-line using your proguard configuration file as the input. You should declare what "-injars"(your .jar file), "-libraryjars"(support library etc.), "-outjars"(location of your obfuscated jar) should be within the proguard config file and run a command similar to this: "java -jar /proguard.jar @proguard.cfg -verbose" within your project folder. – Kerem Aug 19 '14 at 12:20
0

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. Most libraries now need gradle support because applications are now using Android Studio. Mark your project as a library by going to Project -> Properties -> Android and select the Is Library checkbox. Check this link: 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. 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. 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. Use wisely!

sr09
  • 720
  • 5
  • 26