butterknife: Build fails with androidX and jetifier enabled
I migrated my project to androidX. Now I get the following error message on building the project:
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.
Caused by: java.lang.RuntimeException: Failed to transform butterknife-compiler-9.0.0-rc1.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.
gradle.properties:
...
android.useAndroidX=true
android.enableJetifier=true
build.gradle (app module)
...
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '28.0.3'
implementation 'com.jakewharton:butterknife:9.0.0-rc1'
kapt 'com.jakewharton:butterknife-compiler:9.0.0-rc1'
gradle distribution: gradle-4.10.2
I’ve tried using different versions of the artifacts, still getting the same error
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 25
- Comments: 30 (7 by maintainers)
Commits related to this issue
- Work around Jetifier being a thing Closes #1395 — committed to JakeWharton/butterknife by JakeWharton 6 years ago
- fix: Butterknife causing compile Error after migrating to Android X -https://github.com/JakeWharton/butterknife/issues/1395#issuecomment-439776056 — committed to aaroncrutchfield/NatashasHairStudio by aaroncrutchfield 5 years ago
- Update butterknife [9.0.0-rc2 -> 10.2.0]. Avoid Jetifier complaining. https://github.com/JakeWharton/butterknife/issues/1395#issuecomment-439776056 — committed to UweTrottmann/SeriesGuide by UweTrottmann 4 years ago
Well that’s stupid. I guess I’ll just fool it’s logic by splitting the string into two.
See https://issuetracker.google.com/issues/118658603#comment5 for a workaround. No action to take on our side.
It’s not needed with 10.0.0.
The issue was with jetifier not this library.
On Mon, Feb 11, 2019 at 11:11 AM primalbet notifications@github.com wrote: