本文介绍了给定的工件包含字符串文字,该字符串文字具有无法安全地重写的包引用'android.support.v4.content'.对于androidx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我升级了android studio to 3.4 canary
,现在由于以下错误,我无法成功构建:
I upgraded my android studio to 3.4 canary
and now I cannot successfully build anymore due to the following error:
The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.
更多详细信息:
Caused by: java.lang.RuntimeException: Failed to transform '.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/9.0.0-SNAPSHOT/732f93940c74cf32a7c5ddcc5ef66e53be052352/butterknife-compiler-9.0.0-SNAPSHOT.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
很明显,这与Butterknife, androidx and Jetifier
有人知道如何解决此问题吗?
Do anybody know how to fix this?
推荐答案
新的正确答案:
Butterknife 10.0.0添加了对AndroidX的支持.
Butterknife 10.0.0 added support for AndroidX.
dependencies {
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
}
关于黄油刀的旧答案< 10.0.0:
尝试从喷射器中将黄油刀列入黑名单:
Try blacklisting butterknife from the jetifier:
gradle.properties file:
android.jetifier.blacklist = butterknife.*\\.jar
您需要使用AGP的3.3.0-rc1和Kotlin Gradle插件的1.3.0版本:
You need to be on the 3.3.0-rc1 of the AGP and the 1.3.0 version of the Kotlin Gradle plugin:
buildscript {
repositories {
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-rc01'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.0"
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
}
}
这篇关于给定的工件包含字符串文字,该字符串文字具有无法安全地重写的包引用'android.support.v4.content'.对于androidx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!