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

Most upvoted comments

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:

See https://issuetracker.google.com/issues/118658603#comment5 for a workaround. No action to take on our side.

why do i have to put this in every android studio project that i create now? its stupid… and plus i keep getting a warning every time i compile that this is experimental and not stable. can butterknife solve this issue so we don’t have to manually import that in gradle.properties file?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/JakeWharton/butterknife/issues/1395#issuecomment-462386689, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEUF5qF54ZqqaymKffo6R6lfMQswCks5vMZY1gaJpZM4YCxUF .