当前位置: 首页 > 知识库问答 >
问题:

给定的工件包含一个字符串文字,其中包含一个不能安全重写的包引用“android.support.v4.content”。对于androidx

陆绍辉
2023-03-14

我将我的Android Studio升级到3.4金丝雀,现在由于以下错误,我无法成功构建:

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.)

显然,它与巴特刀,机器人和喷气机有关

有人知道如何解决这个问题吗?

共有3个答案

耿俊彦
2023-03-14

对于androidx,只需将您的依赖项升级到版本“10.0.0”

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

在此处查找文档

宋畅
2023-03-14

添加最新版本的butterknive依赖项,如果它发生更改,可以在此处查看(https://github.com/JakeWharton/butterknife). 它支持androidX。然后转到你的应用程序构建梯度,用以下内容替换旧版本:

dependencies {
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
}
丁俊智
2023-03-14

新的正确答案:

黄油刀10.0.0增加了对AndroidX的支持。

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

Butterknife的老答案

尝试从喷射器中将毛刀列入黑名单:

gradle.properties file:

android.jetifier.blacklist = butterknife.*\\.jar

你需要在3.3.0-rc1的AGP和1.3.0版本的静态编程语言Gradle插件:

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'
    }
}
 类似资料:
  • 问题内容: java中有没有一种方法可以用指定数量的指定字符创建字符串?就我而言,我需要创建一个包含10个空格的字符串。我当前的代码是: 有没有更好的方法来完成同一件事。特别是我想快速(在执行方面)。 问题答案: for循环将由编译器优化。在像您这样的情况下,您无需自己担心优化。信任编译器。 顺便说一句,如果有一种方法可以创建一个包含n个空格字符的字符串,那么它的编码方式就和您刚才一样。

  • null 我对解析和的最佳猜测如下。此regex似乎将所有输入计算为:

  • 问题内容: 要查找当前文件夹中所有包含“ foo”的文件,我使用: 要查找当前文件夹中所有包含“ bar”的文件,我使用: 但是,如何查找不包含“ foo”和“ bar”的所有文件? 问题答案: 要打印 线 不包含某些字符串,可以使用标志: 这样就为您提供了 不 包含或的所有行。 要打印不包含某些字符串的 文件 ,请使用该标志。要不匹配多个字符串,可以将正则表达式与标志一起使用(可以使用多个reg

  • 假设我需要一个regex来验证,例如,一个在任何地方都只包含一个字符的句子。 怎么做?

  • 题目描述 给定两个分别由字母组成的字符串A和字符串B,字符串B的长度比字符串A短。请问,如何最快地判断字符串B中所有字母是否都在字符串A里? 为了简单起见,我们规定输入的字符串只包含大写英文字母,请实现函数bool StringContains(string &A, string &B) 比如,如果是下面两个字符串: String 1:ABCD String 2:BAD 答案是true,即Stri