I just have migrated my project to AndroidX. Sync and build phase are ok, but when I try to run the compiler show me this error:
error: package android.support.annotation does not exist
This error raises on a builded file
// Generated code from Butter Knife. Do not modify!
package com.xdatanet.cda.Adapters;
import android.support.annotation.CallSuper; //<-- Doesn't exists
import android.support.annotation.UiThread; //<-- Doesn't exists
import android.view.View;
import android.widget.ImageView;
import butterknife.Unbinder;
import butterknife.internal.Utils;
import com.xdatanet.cda.CustomView.CDATextView;
import com.xdatanet.cda.R;
import java.lang.IllegalStateException;
import java.lang.Override;
public class CommunicationAdapter$CommunicationViewHolder_ViewBinding implements Unbinder {
private CommunicationAdapter.CommunicationViewHolder target;
@UiThread //<-- First error
public CommunicationAdapter$CommunicationViewHolder_ViewBinding(CommunicationAdapter.CommunicationViewHolder target,
View source) {
// Some generated code
}
@Override
@CallSuper //<-- Second error
public void unbind() {
// Some generated code
}
}
Gradle properties
android.enableJetifier=true
android.useAndroidX=true
Butterknife implementation into gradle
implementation "com.jakewharton:butterknife:8.8.1"
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"
The IDE says Files under the "build" folder are generated and should not be edited.
It seems to be an error with butterknife but I don't know why.
With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar. The refactor command makes use of two flags. By default, both of them are set to true in your gradle.
The Android Extension Library, often known as AndroidX, is the new open-source project that is a significant upgrade to the original Android Support Library and can be used to develop, test, package version, and release libraries within Jetpack. The Android Jetpack libraries are part of the AndroidX namespace.
I would suggest updating ButterKnife to the newest version.
I haven't migrated my projects to AndroidX yet, but from the commit history on the ButterKnife github page, it would seem like that the newest 9.0.x versions support AndroidX.
https://github.com/JakeWharton/butterknife
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With