Android Studio编译时Error: app:transformClassesAndResourcesWithProguardFor 的解决
Posted YuNansen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Studio编译时Error: app:transformClassesAndResourcesWithProguardFor 的解决相关的知识,希望对你有一定的参考价值。
最近在弄android Studio的Gradle文件,发现自己的项目有个地方一直编译不过去,报的错误如下:
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Response$Builder
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Headers
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.ResponseBody
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Response$Builder
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.ResponseBody
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Response
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Response$Builder
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Response
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Response$Builder
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Response
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Response$Builder
Warning:io.bugtags.agent.instrumentation.okhttp3.ResponseBuilderExtension: can't find referenced class okhttp3.Response
Warning:there were 528 unresolved references to classes or interfaces.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForDfy_dev_Release'.
> java.io.IOException: Please correct the above warnings first.
Information:BUILD FAILED
Information:Total time: 1 mins 22.716 secs
Information:1 error
Information:278 warnings
Information:See complete output in console
可以看到错误是出在app:transformClassesAndResourcesWithProguard阶段,也就是Proguard混淆可能出现了问题。同时从上面的logcat可以看出,错误的地方应该是bugtags下面相应的逻辑。
bugtags是一个捕捉bug的sdk,那么在它的文档里应该在proguard-rules.pro有相应的配置,那么找到配置,如下:
# ProGuard configurations for Bugtags
-keepattributes LineNumberTable,SourceFile
-keep class com.bugtags.library.** *;
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.bugtags.library.**
# End Bugtags
那么经过查阅资料,改为下面的代码可以通过编译:
# ProGuard configurations for Bugtags
-keepattributes LineNumberTable,SourceFile
-keep class com.bugtags.library.** *;
-keep class io.bugtags.** *;
-dontwarn io.bugtags.**
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.bugtags.library.**
# End Bugtags
可以看到,加了中间的两行:
-keep class io.bugtags.** *;
-dontwarn io.bugtags.**
这两行代码可以保证我们的应用编译通过,而不会导致出现由于库找不到而产生的崩溃性bug。
gradle文件和我们所加的第三方库经常会有一些冲突,上面的问题可能只是其中一种情况。如果大家对我的解决方法有什么建议的话,希望提出来。
以上是关于Android Studio编译时Error: app:transformClassesAndResourcesWithProguardFor 的解决的主要内容,如果未能解决你的问题,请参考以下文章
错误记录Android Studio 编译报错 ( VirtualApp 编译 NDK 报错 | Error:A problem occurred configuring project ‘: )(代
错误记录Android Studio 编译报错 ( AAPT: error: failed to read PNG signature: file does not start with PN )
错误记录Android Studio 编译时 lint 检查报错 ( Error: Google Play requires that apps target API level 29 or )
错误记录Android Studio 编译报错 ( Error:Connection timed out: connect | 更新配置依赖仓库方式 )
错误记录Android Studio 编译报错 ( Error:Connection timed out: connect | 更新配置依赖仓库方式 )