4

My aim is to be able to distribute the android library application only as binary(WITHOUT SOURCE) to other developers. So that they can make their own apps with it.

I am developing two android applications. The first one is library application should act as a kind of SDK. The second one application should use the library application and make the original app.

I am using android studio to develop the applications. I have completed the implementations of the library application and generated the .aar.

Now I am using my own SDK(.aar) to build the second application. I can use the .aar in my second application.

The problem is that, android studio can decompile my SDK(.aar). But I don't want to share the source code.

Note: My librarySDK doesn't contain any UI elements such as Activity, Resources.

Is there any way to create the SDK(.aar) without source code?

SKK
  • 1,705
  • 3
  • 28
  • 50

1 Answers1

3

yup for that you need to use proguard when you build SDK/Library aar file

Change minifyEnabled to true in your SDK/Library gradle

buildTypes {
        release {
            minifyEnabled true //enable proguard
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

Enabling ProGuard in Eclipse for Android

Community
  • 1
  • 1
Madhur
  • 3,303
  • 20
  • 29
  • Thanks for the response. I added this and I got the below exception during compilation. Error:Execution failed for task ':libraryapp'. > java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options? – SKK Jan 28 '16 at 07:21
  • yes you will get alot of error because of obfuscation and yes you need to specify '-keep' or '-dontwarn' – Madhur Jan 28 '16 at 07:23
  • check this out https://www.quora.com/What-are-the-steps-to-enable-ProGuard-in-Android-Studio – Madhur Jan 28 '16 at 07:24