The given artifact contains a string literal with a package reference ´android.support.v4.content´ that cannot be safely rewritten.
2021-01-20 17:11:29  By: shinyuu

我的 Android 项目采用的是 AndroidX,我首先使用的是butterknife 8.5.1版本,报错,提示我用butterknife 9.0 以上,我使用butterknife 9.0,继续报上面的错误;解决方法:使用butterknife 10.1.0 即可,报错信息如下:

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.
	


添加依赖到项目中:

buildscript {
  repositories {
    mavenCentral()
    google()
   }
  dependencies {
    classpath ´com.jakewharton:butterknife-gradle-plugin:10.1.0´
  }
}


mouble 依赖

也就是 app 依赖,头部添加:

apply plugin: ´com.jakewharton.butterknife´


jar 包依赖:

android {
  ...
  // Butterknife requires Java 8.
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

dependencies {
  implementation ´com.jakewharton:butterknife:10.1.0´
  annotationProcessor ´com.jakewharton:butterknife-compiler:10.1.0´
}


其实也可以打开butterknife 的 github 地址,查找最新的版本。


快速评论


技术评论

  • 该技术还没有评论、赶快抢沙发吧...
DD记账
top
+