2016-11-20 120 views
1

我最近從eclipse切換到Android Studio,並開始對我的android應用使用gradle。 我一直在嘗試在Android Studio中構建我的apk文件時遇到了一些警告。 以下是錯誤日誌:在Android Studio中無法避開帶gradle和proguard的警告

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

嘗試

-keep class org.apache.commons.** { 
    *; 
} 

,而不是

-keep class org.apache.commons.** 
+0

謝謝,但問題仍然存在。 – Luigi04