Reputation: 6241
I have a android library with one class and I want to make it an .aar library. When I set minifyEnabled
to true, another android project cannot use the library (It is fine if minifyEnabled
is set to false). I would like to ask what is the correct configuration of proguard with AAR library
HelloWorld.java
package com.example.hello;
import android.util.Log;
public class HelloWorld {
public static void Hello(){
Log.v("HelloWorld","Hello World!");
}
}
build.grandle
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
}
proguard-rules.pro
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
-keep class com.example.hello {public *;}
Upvotes: 4
Views: 9054
Reputation: 1940
Try changing the last line in proguard-rules to
-keep class com.example.hello.** {public *;}
As for Android Studio being able to decompile, you can't prevent that. If you want to protect your code, I suppose the best you can do is to obfuscate most of it, and then extend the desired functionality through interfaces that you do not obfuscate by adding the relevant proguard rules.
Upvotes: 8
Reputation: 227
Any APK can be decompiled. Proguard just makes the decompiled codes more difficult to understand
Upvotes: 1