Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
给定工件包含一个带有包引用的字符串文本';android.support.v4.content';这是无法安全重写的。对于androidx_Android_Butterknife_Androidx_Android Jetifier - Fatal编程技术网

给定工件包含一个带有包引用的字符串文本';android.support.v4.content';这是无法安全重写的。对于androidx

给定工件包含一个带有包引用的字符串文本';android.support.v4.content';这是无法安全重写的。对于androidx,android,butterknife,androidx,android-jetifier,Android,Butterknife,Androidx,Android Jetifier,我将我的android studio升级为3.4 canary,现在由于以下错误,我无法再成功构建: 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

我将我的
android studio升级为3.4 canary
,现在由于以下错误,我无法再成功构建:

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,您会选择哪个版本?最新版本9.0.0-rc2支持androidx

UPD:butterknife上有一个已关闭的问题


将android.jetifier.blacklist=butterknife编译器添加到gradle.properties文件。

新的正确答案:

Butterknife 10.0.0增加了对AndroidX的支持

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

黄油刀<10.0.0的旧答案:

尝试将黄油刀从jetifier中列入黑名单:

gradle.properties file:

android.jetifier.blacklist = butterknife.*\\.jar
您需要使用AGP的3.3.0-rc1和Kotlin Gradle插件的1.3.0版本:

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'
    }
}

添加butterknive依赖项的最新版本。如果它发生更改,您可以在此处进行检查()。 它支持androidX。然后转到你的应用程序构建梯度,并用以下内容替换旧版本:

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

使用最新版本的Butterknife解决了该问题。使用>=9.0.0-rc2(Butterknife版本)支持androidX。
有关最新版本,请查看链接-

将ButterKnife升级到最新版本,并确保将其添加到您的版本中。gradle(应用程序):


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

dependencies {
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
}
查找文档

更改

或其他物质主题。
在Android Studio 4.0.1中以“无活动”启动新项目后出现此错误

我的项目不使用butterknife,但我遇到了相同的错误“给定的工件包含一个字符串文字,其包引用'android.support.v4.widget'无法安全重写。需要手动更新使用反射(如注释处理器)的库,以添加对androidx的支持 " 这就是我为解决这个问题所做的:更新您的parceler版本

渐变生成文件

替换:

annotationProcessor 'org.parceler:parceler:1.1.6'
implementation 'org.parceler:parceler-api:1.1.6'
与:


更新butterknife+使缓存无效并重新启动+同步gradle
如果未使用buterknife,请清除缓存并重新启动

尝试此操作:但没有luckWhat是您尝试添加到黑名单的正则表达式?给定的工件包含一个字符串文字,其包引用为“android.support.v4.widget”,无法安全重写。需要更新使用反射(如注释处理器)的库手动编辑以添加对androidx的支持。当我尝试使用minifyenabled和shrinkresources设置为true创建签名apk时,我收到了上述错误。我可以在emulator或设备中运行应用程序。如何解决此问题?问得好!非常有用,谢谢我使用9.0.0-rc2,我得到了与您所看到的完全相同的错误不要添加android.jetifier.blacklist=butterknife.\\\\.jar,因为我测试了它不起作用。你只添加classpath'com.jakewharton:butterknife gradle plugin:9.0.0-rc2',然后在调试和导出文件apk时它就会起作用,没有问题。更多信息可以在这里找到这个答案是正确的,但请看一下:将butterknife更新为10,也解决问题这是一个更好的解决方案。此解决方案对于调试生成工作正常,但我无法创建签名版本APK。给定的工件包含一个字符串文字,其包引用为“android.support.v4.widget”,无法安全重写。需要手动更新使用反射(如注释处理器)的库以添加支持对于androidx.very help,感谢您最好的回答,升级后我搜索了此解决方案-->错误:静态接口方法仅从Android N(--min api 24)开始支持:void butterknife.Unbinder.lambda$Static$0()爱你的人,你做到了…我浪费了半天的时间来搜索答案。我的点击编辑文本框给出了空指针。它不是初始化。
annotationProcessor 'org.parceler:parceler:1.1.6'
implementation 'org.parceler:parceler-api:1.1.6'
  annotationProcessor 'org.parceler:parceler:1.1.13'
  implementation 'org.parceler:parceler-api:1.1.13'