我有一个包含一个类的Android库,我想将其制作成.aar库。当我将minifyEnabled
设为true时,另一个Android项目无法使用该库(如果将minifyEnabled
设置为false则正常)。我想问一下,AAR库的Proguard正确配置是什么。
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 *;}
-keep class com.example.hello.** {public *;}
? - Anuj