Search code examples
androidandroid-libraryandroid-proguardaar

How to distribute a SDK as AAR file without exposing the source code?


I want to distribute an SDK to end developers but I don’t want to share my code. I have used AAR file to share my SDK (Android Archive Library (aar) vs standard jar). But there is a possibility that others can view my class files. How to avoid that? Please help us.

Note: I had review this “Android - Need a way to create the library(.aar file) without source code” but it didn’t solve my problem.


Solution

  • Proguard cuts unused classes. Libraries are standalone products, and has some specific entry points, which should not be obfsuscated. So you need to add rules to keep this entry points. Rules lookes like this:

    -keep class packagename {public *;}

    But, Proguard but will not encrypt strings.

    Dexguard is a paid tool that includes string encryption and other features.

    For a full comparison see this chart: https://www.saikoa.com/comparison-proguard-and-dexguard