我最近从eclipse切换到Android Studio并开始使用gradle for my android app。 在尝试在Android Studio中构建我的apk时,我一直在与一些警告作斗争。 这是错误日志:
Error:this warning is that reflective operations on this class will incorrectly
Error:compiler that did not target the modern .class file format. The recommended
Error:indicate that it is *not* an inner class.
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:(org.apache.commons.collections.BeanMap$5) that doesn't come with an
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:solution is to recompile the class from source, using an up-to-date compiler
我的build.gradle
repositories {
mavenCentral()
}
apply plugin: 'com.android.application'
android {
lintOptions {
abortOnError false
}
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
targetSdkVersion 24
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildTypes {
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-android.txt'
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-android.txt'
}
}
}
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
}
dependencies {
compile 'com.github.paolorotolo:appintro:4.1.0'
compile 'com.opencsv:opencsv:3.8'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.github.tonivade:tinydb:0.7.1'
}
我尝试过不同的proguard选项,但都没有解决问题:
-keepattributes EnclosingMethod
-keepattributes InnerClasses
-dontwarn org.apache.commons.**
-keep class org.apache.commons.**
有人知道如何解决这个问题吗? 非常感谢!
答案 0 :(得分:0)
尝试
-keep class org.apache.commons.** {
*;
}
而不是
-keep class org.apache.commons.**