I upgraded my android studio to 3.4 canary
and now I cannot successfully build anymore due to the following error:
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.
More details:
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.)
Clearly, its something to do with Butterknife, androidx and Jetifier
Do anybody know how to fix this?
New correct answer:
Butterknife 10.0.0 added support for AndroidX.
dependencies {
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
}
Old answer for Butterknife < 10.0.0:
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'
}
}