1

I need to delivery my code as a library. I've created it and now I need to obfuscate mainly all the code except the public classes that the final user of my library will need.

My library has 2 packages:

    1. package com.xxx.xxx where is locate all the public classes.
    1. package com.yyy.yyy where there are a lot classes that has to be obfuscate (nobody should see the content of it).
    1. Also, my library use one internal library com.zzz.zzz

The classes from the first packet mainly don't have code, only public interfaces and some listener classes, so the core is in the 2nd package which must be private.

In my proguard file I have these commands:

-keep public class com.xxx.xxx.* 
-keepclasseswithmembernames class com.xxx.xxx.* {
    native <methods>;
}
-keepclassmembers public class com.xxx.xxx.* {
    *;
}

It is ok, everything compile and I can run one mock-app using the library but when I try to use whatever class from the com.yyy.yyy there is a NoClassDefFoundError in runtime.

Not sure if I should add something in the proguard file, or maybe the problem is about the internal library compiled in my library (com.zzz.zzz).

My code in the build gradle file is:

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

Any idea please about what could happen? Thanks in advance.

Juan Pedro Martinez
  • 1,924
  • 1
  • 15
  • 24
  • explicitly tell proguard config to keep your yyy.yy packages ... http://stackoverflow.com/questions/7721397/how-to-make-proguard-ignore-external-libraries – Robert Rowntree Apr 20 '16 at 16:23
  • Thanks Robert...I tried to "keep" the external library com.zzz.zzz and now everything is working properly. I think the NoClassDefFoundError exception was caused because some classes from com.yyy.yyy were using the external libraries...so half problem resolved...but now the external libraries are public for the user of the library...how I can avoid it? Now the user of my library has access to com.xxx.xxx which is ok and also to com.zzz.zzz which is not ok – Juan Pedro Martinez Apr 21 '16 at 07:38
  • only com.xxx.xxx must be public and accesible to the Third-party user – Juan Pedro Martinez Apr 21 '16 at 07:42

0 Answers0