I try to encrypt classes in my android library project. But I cannot do that. Variables and strings are changed by dexguard, but there is no impact from -encryptclasses. I receive logs in build output:
Warning: not encrypting kept class com.justexample.SomeClass1
Warning: not encrypting kept class com.justexample.SomeClass2
Warning: the configuration specifies to encrypt 2 classes that it keeps at the same time.
Not encrypting those classes to avoid problems at runtime.
Note: inner class com.justexample.SomeClass1 is unencrypted, while its outer class is encrypted.
Note: inner class com.justexample.SomeClass2 is unencrypted, while its outer class is encrypted.
Note: one or more encrypted classes have unencrypted inner classes.
My dexguard-project.txt is:
-verbose
-encryptstrings com.justexample.SomeClass1
-encryptclasses com.justexample.SomeClass1, com.justexample.SomeClass2
And my gradle for module:
apply plugin: 'com.android.library'
apply plugin: 'dexguard'
android {
compileSdkVersion 25
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName gitVersionName()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFile getDefaultDexGuardFile('dexguard-library-release.pro')
proguardFile 'dexguard-project.txt'
}
}
sourceSets { main {
assets.srcDirs = ['src/main/assets', 'src/androidTest/assets/']
} }
}
dependencies {
//my dependecies
}
You are using the default library configuration: dexguard-library-release.pro which will by default keep all public / protected classes.
You can not encrypt classes that are kept.
To solve that issue, use the aggressive configuration: dexguard-library-release-aggressive.pro and specify the public API of your library which should not be obfuscated.
Dont forgot to also use -repackageclasses com.mypackage.internal
to move all obfuscated classes into this package.