闲着无聊升级了下 com.jakewharton 的版本到 10.1.0,配置如下:
classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0'
以及在各module中配置:
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
结果编译的时候出现以下警告
:
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
Affected Modules: app
这个估计又是Gradle版本方法和com.jakewharton:butterknife脚本之间的的api不匹配的问题,毕竟github上的commit已经是好几个月之前,而Gradle则刚刚更新不久,我使用的Gradle是3.4.1 version。
那么解决的办法有哪些呢,通过强大的谷歌我们发现了两个解决办法。
第一种解决办法
由于是版本不匹配,那么降低某个版本的API肯定是OK的。
这里降低Gradle 3.4.1
的版本,即从3.4.1降低到3.0.1版本。
通过测试该Warning得到解决。
第二种解决办法
GitHub上从来不缺乏牛人,其实这个Warning已经被很多人提到了GitHub上,且该issue未曾关闭。
issue的讨论入口:https://github.com/JakeWharton/butterknife/issues/1431
在讨论区中有一个大神贴出了自己的解决办法,即自己动手将 .processResources is unwrapped to .getProcessResources.
大神已经贴出自己的解决方案,直接使用即可,在build.gradle中直接改成如下:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
mavenCentral()
google()
jcenter()
}
dependencies {
// https://github.com/JakeWharton/butterknife/pull/1478
// https://jitpack.io/com/github/TWiStErRob/butterknife/fix1431-SNAPSHOT/build.log
classpath 'com.github.TWiStErRob.butterknife:butterknife-gradle-plugin:fix1431-SNAPSHOT'
}
}
未曾测试,因为明哥觉得第三种解决办法更加好。
第三种解决办法
没错,依然是讨论区的答复,那就是直接忽视这个Warning,因为这个Warning实际上并不妨碍整个工程的编译以及apk的生成。
冷静,忽视,就不是问题啦~~~此方法对于洁癖码农无效哈。