I want to build an .aar library and proguard classes, but my library proguard file doesn't work, and I can see clear classes.
Here is my proguard file:
android {
buildTypes {
release {
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules-my-lib.pro'
}
}
}
and app/build.gradle:
android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Create a Android Studio Project and convert it to library Follow this link . Build and Execute the command Generate APK, .aar file will be created in release/debug folder.
Write the proguard rules as similar to APK, it will apply to .aar file also.
I hope this helps
While you can probably shrink and obfuscate the library itself, the usual practice is to leave minifyEnabled
as false
and provide the proguard configuration to the application, using consumerProguardFiles
instead of proguardFiles
.
This means that the minification is applied only once, on the whole application, using the merged configuration from the app's proguardFiles
and the libraries consumerProguardFiles
. This is usually more efficient because parts of the libraries not actually used by the application can be removed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.