Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android X support #1280

Closed
xTheITx opened this issue May 15, 2018 · 17 comments
Closed

Android X support #1280

xTheITx opened this issue May 15, 2018 · 17 comments

Comments

@xTheITx
Copy link

xTheITx commented May 15, 2018

I've recently attempted to upgrade a project which uses Butterknife v8.8.1 to make use of the new Android X libraries by using the jetifier tool in Android Studio.

The project fails to compile as the generated _ViewBinding classes reference the old android.support.annotation. annotations which no longer exist.
There may also be additional issues I'm not aware of.

I was just wondering if there was a plan to migrate over to reference the new androidx package names in the generated code.

I'm not familiar with the Butterknife code, but let me know if there's anything I could contribute to the project to facilitate adding support.

Thank you for your time

@scarrie
Copy link

scarrie commented May 18, 2018

I got my app compiling by adding my own copies of the old package "android.support.annotation"s for @callsuper and @UiThread.

@Retention(CLASS) @Target({METHOD,CONSTRUCTOR,TYPE,PARAMETER}) public @interface UiThread { }

@Retention(CLASS) @Target({METHOD}) public @interface CallSuper { }

Its a start, but then I hit further problems caused by this new jetifier process with other libraries. Guess we just have to be patient to wait for all these third party libraries to update.

@allidoiswarren
Copy link

I'll take a crack at this.

@JakeWharton
Copy link
Owner

Merged

@justine-george
Copy link

I'm sorry to say the error still persists.

@naturalwarren
Copy link
Contributor

Can you paste the stack trace? Are you building against a JAR cut from master?

@ArunPandiyan
Copy link

It's from the import statement for the annotations which is found in the auto generated viewbinding files.

@k4dima
Copy link

k4dima commented Jul 1, 2018

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'

@danielwilson1702
Copy link

Um, in terms of production code how safe is this on a scale of 1-10 where 1="wtf are you doing this shouldn't be in the same room as a production app"

@feinstein
Copy link

repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'

This isn't working for me

@feinstein
Copy link

Ok, now it works, just be sure to put it inside the repositories inside allprojects and not the one inside buildscript

@adityathakar
Copy link

Is it safe to use 9.0.0-SNAPSHOT version in production code?

@SyedNabil
Copy link

In case like me you are confused about the gradle settings, you can find the complete solution to this as a stack overflow answer: https://stackoverflow.com/a/52308912/10224384

@kagile
Copy link

kagile commented Oct 9, 2018

Please publish releases instead of snapshots or please leave a note. Shall I update README?

@siavash-sajjad
Copy link

Hello
i get error when use androidX

`* What went wrong:
Could not resolve all files for configuration ':View:debugAnnotationProcessorClasspath'.

Failed to transform file 'butterknife-compiler-8.8.1.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
Failed to transform 'C:\Users\sadegh-Pc.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife-compiler\8.8.1\b2f4505a1babb7b7c11abbbf8ea4c90b18c3aeac\butterknife-compiler-8.8.1.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.)
`

how to fix it?

@aaronweihe
Copy link

@siavash-sajjad try butterknife 9+ first. then you'll need to add android.jetifier.blacklist=butterknife-compiler to gradle.properties to exclude butterknife compiler from being jetified

@mutwakilmo
Copy link

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

@ZakAnun
Copy link

ZakAnun commented Apr 24, 2020

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

It works for me, thanks~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests