Could not get unknown property 'packageForR' for task...问题解决

本文详细介绍了在更新AndroidStudio至3.2版本后,编译旧项目时遇到的ButterKnife相关错误及其解决方案。通过调整ButterKnife的配置,即删除插件并使用annotationProcessor,成功解决了编译问题。

发现问题:

在更新了Android studio 3.2之后,编译一个旧的项目时出现以下报错:

Could not get unknown property 'packageForR' for task ':app:processProduct1DebugResources' of type com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.

编译时时的参数如下:
buildToolsVersion “28.0.2”
targetSdkVersion=26
gradle-4.6

Google之后在stackoverflow 上找到了答案:
问题出现在ButterKnife插件上
由于项目中使用了butterknife
在module/build.gradle的 对butterknife的配置如下:

apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'

...

dependencies {
    ...
    implementation 'com.jakewharton:butterknife:8.5.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

}

解决问题:

只需删除ButterKnife gradle插件,然后使用annotationProcessor +实现版本。见下面的步骤:
1.apply plugin: 'com.jakewharton.butterknife’在gradle中删除
2.只需在gradle中使用/添加以下依赖项:

dependencies {
    implementation 'com.jakewharton:butterknife:8.5.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}

重新编译即可。

参考:https://stackoverflow.com/questions/48713415/could-not-get-unknown-property-packageforr-for-task-processdebugresources/50146410

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值