The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. for androidx

五迷三道 提交于 2019-11-29 00:57:24

Try blacklisting butterknife from the jetifier:

gradle.properties file:

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

You need to be on the 3.3.0-rc1 of the AGP and the 1.3.0 version of the Kotlin Gradle plugin:

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

Add the last version of the butterknive dependency you can check it here if it changes (https://github.com/JakeWharton/butterknife). It supports androidX. Then go to your app build graddle and replace the old version with the following:

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

For androidx simply upgrade your dependencies to version '10.0.0'

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

Look for documentation here

Upgrade ButterKnife to latest version and make sure to add these into your build.gradle(app):

android {
...
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

Which version if Butterknife you use? Latest version 9.0.0-rc2 supports androidx.

UPD: There is closed issue on butterknife's github repo. Temporary workaround

Add android.jetifier.blacklist=butterknife-compiler to your gradle.properties file.

Using the latest version of Butterknife resolved the issue. Use >= 9.0.0-rc2 (Butterknife Version) to support androidX. For the latest release check the link - https://github.com/JakeWharton/butterknife/releases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!