如何使用Gradle抑制“警告:忽略匿名内部类的InnerClasses属性”?

如何使用Gradle抑制“警告:忽略匿名内部类的InnerClasses属性”?

  • 这不是一个重复的问题
  • 这不是在Proguard期间,我也不想压制使用Proguard
  • 我想压制正常的./gradlew assembleDebug (因为这是assertj-core./gradlew testDebug

相关性:

 dependencies { testCompile "org.assertj:assertj-core:1.7.1" } 

警告:

 Dex: warning: Ignoring InnerClasses attribute for an anonymous inner class (org.assertj.core.internal.cglib.reflect.FastClassEmitter$3) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. 

就像是:

 tasks.withType(JavaCompile) { sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 configure(options) { compilerArgs << "-Xlint:-options" // Turn off "missing" bootclasspath warning } } 

我可以添加什么compilerArgs来抑制此警告?

参考文献:

  • 我在这里有一个答案,但没有一个能够抑制这个警告: 在用gradle编译android库时如何抑制警告?

我之前尝试使用第三方库时遇到了同样的问题。 该lib是为Java 1.3编译的。 我能够通过获取该lib的源代码并自行构建一个jar文件来修复它。 当然,这只适用于该lib的源可用并且可以构建。

替换未选中的@SuppressWarnings("unchecked")没有帮助? 更多示例如下: http : //www.codejava.net/java-core/the-java-language/suppresswarnings-annotation-examples