解决:The given artifact contains a string literal with a package reference ‘android.support.v4.content

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.

给定的工件包含一个字符串字面量,包含一个包引用'android.support.v4。无法安全地重写的内容。使用反射(如注释处理器)的库需要手动更新,以添加对android的支持。

这是github上下载的一个老项目,结果报错。

致使问题原因是:项目引用了AndroidX的依赖包,但是项目中的依赖是引用之前的 support.v4.content等 包实现的,因此产生冲突。

将项目中的依赖替换成:

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

注意再把项目中的support切换成androidX的依赖包。

猜你喜欢

转载自blog.csdn.net/qq_33721320/article/details/124180087