繁体   English   中英

如何修复 androidx 中的“android.support.v4.content”?

[英]How to fix 'android.support.v4.content' in androidx?

我将我的 android 旧项目迁移到 androidx 以使用更新的库并修复依赖项。 但它仍然导致以下问题。 并且应用程序没有被编译。 我该如何解决这个问题? 有什么想法吗?

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.

Butterknife 10.0.0 添加了对 AndroidX 的支持。 更改黄油刀依赖版本为我解决了它

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

请尝试使用以下设置:

  implementation 'com.jakewharton:butterknife:10.2.1'
  annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'

按着这些次序。

  • 首先通过更新您的项目迁移到 AndroidX 使用此版本的支持库:版本 28.0.0。

  • 从菜单栏中重构 > 迁移到 AndroidX。

  • 重构命令使用两个标志。 默认情况下,它们在 gradle.properties 文件中都设置为 true: android.useAndroidX=true

  • Android 插件使用适当的 AndroidX 库而不是支持库。 android.enableJetifier=true Android 插件通过重写二进制文件自动迁移现有的第三方库以使用 AndroidX。

请尝试使用以下设置:

实现“com.jakewharton:butterknife:(插入最新版本)”

annotationProcessor 'com.jakewharton:butterknife-compiler:(插入最新版本)'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM