2016-10-05 272 views
15

如何使用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要禁止这种警告?

参考文献:

+0

为什么不使用proguard? – cipley

+0

@vityy这发生在组装上。 –

回答

1

我有同样的问题,当我试图使用第三方库一会儿前。该库是为Java 1.3编译的。我能够通过获取该lib的源代码并自行构建一个jar文件来修复它。当然,这只适用于该lib的源文件可用并可供构建的情况。

+0

好的。我宁愿不编译和重新包装'assertj-core'。我只想“沉默”Gradle。 –

+0

偶然我偶然发现了另一个类似的问题。也许这个问题的答案是有帮助的:http://stackoverflow.com/a/40173052/5956451 – Thomas

+0

我使用'assertj-core'进行单元测试。这不会被编译到应用程序,所以我不会运行proguard反对它。 –

相关问题