Butterknife: 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.

Created on 3 Dec 2018  路  8Comments  路  Source: JakeWharton/butterknife

I'm Trying to implement butterknife:9.0.0-rc2 with Dagger 2.19 and Jetifier = enable, but i get the next 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.

How can solve this issue?

thanks for your kind help.

Most helpful comment

Change to these parameters in build.gradle, it worked for me using version butterknife:10.2.1

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

All 8 comments

See https://github.com/JakeWharton/butterknife/issues/1395#issuecomment-439776056 for a workaround of this jetifier problem. No action to take on our side.

I get the same error , I migrated my existing project to androidx thats when i got this error, tried upgrading version to 10.2.0 and added compileOptions in build.gradle.
The findById is not recognized. Some workAround for this?? Thank you.

Is there any solution yet. I have stuck after migrating my project to androidx.

Change to these parameters in build.gradle, it worked for me using version butterknife:10.2.1

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

Hi
I am also facing same issue after made below changes also & I am not able to run test cases

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

I also got the same issue. Please share the best solution for it.

The given artifact contains a string literal with a package reference 'android.support.v4.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.

Used libraries

implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.core:core:1.0.0'
implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
implementation 'androidx.media:media:1.0.0'
implementation 'androidx.fragment:fragment:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.mediarouter:mediarouter:1.0.0'
implementation 'androidx.emoji:emoji-appcompat:1.0.0'
implementation 'androidx.emoji:emoji-bundled:1.0.0'
implementation 'androidx.emoji:emoji:1.0.0'
compileOnly 'javax.annotation:jsr250-api:1.0'
implementation 'com.github.hani-momanii:SuperNova-Emoji:1.1'
implementation 'org.jsoup:jsoup:1.10.3'
implementation 'com.leocardz:link-preview:1.2.2@aar'
implementation 'com.koushikdutta.urlimageviewhelper:urlimageviewhelper:1.0.4'
implementation 'net.openid:appauth:0.2.0'
implementation "com.onesignal:OneSignal:$oneSignalVersion"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation "com.google.android.gms:play-services-maps:$gplayVersion"
implementation "com.google.android.gms:play-services-location:$gplayVersion"
implementation "com.google.android.gms:play-services-gcm:$gplayVersion"
implementation "com.google.android.gms:play-services-auth:$gplayVersion"
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.google.maps.android:android-maps-utils:0.5+'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.6.3'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'androidx.annotation:annotation:1.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.uphyca:stetho_realm:2.0.0'
implementation 'net.sf.supercsv:super-csv-java8:2.4.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.malinskiy:superrecyclerview:1.1.4'

implementation 'org.parceler:parceler-api:1.1.5'
implementation 'io.realm:android-adapters:1.3.0'
implementation 'net.danlew:android.joda:2.9.4.2'
implementation 'com.squareup.wire:wire-runtime:1.2.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.jakewharton:butterknife:10.0.0'

annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'com.timehop.stickyheadersrecyclerview:library:0.4.3'
implementation 'com.squareup:otto:1.3.8'
implementation 'com.vdurmont:emoji-java:3.3.0'
implementation 'com.google.android:flexbox:0.3.1'
implementation 'org.apache.commons:commons-lang3:3.5'
implementation 'com.github.barteksc:android-pdf-viewer:2.7.0'
implementation 'com.github.barteksc:pdfium-android:1.7.0'
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
implementation 'com.wang.avi:library:2.1.3'
implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation "com.google.dagger:dagger-android:$daggerVersion"
implementation "com.google.dagger:dagger-android-support:$daggerVersion"
implementation "com.google.dagger:dagger:$daggerVersion"
implementation 'org.apache.commons:commons-lang3:3.6'
implementation('com.crashlytics.sdk.android:answers:1.4.2@aar') {
transitive = true
}

Change to these parameters in build.gradle, it worked for me using version butterknife:10.2.1

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.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.
i am getting this error

I had exactly the same problem

I have made the following changes namely

implementation 'com.jakewharton:butterknife:9.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0'

to
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

momochenxx picture momochenxx  路  3Comments

alejandro-pnz picture alejandro-pnz  路  3Comments

shehabic-work picture shehabic-work  路  3Comments

engr-umar-qureshi picture engr-umar-qureshi  路  3Comments

ZakTaccardi picture ZakTaccardi  路  3Comments