迁移AndroidX运行错误android.support.annotation不存在
Migrating AndroidX run error android.support.annotation does not exist
我刚刚将我的项目迁移到 AndroidX。同步和构建阶段没问题,但是当我尝试 运行 时,编译器向我显示此错误:
error: package android.support.annotation does not exist
构建文件时出现此错误
// 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 属性
android.enableJetifier=true
android.useAndroidX=true
Butterknife 实施到 gradle
implementation "com.jakewharton:butterknife:8.8.1"
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"
IDE 表示 Files under the "build" folder are generated and should not be edited.
- Android Studio 3.2.1
- 最小 SDK 19,最大 SDK 28
- Gradle 版本 3.2.1
好像是 butterknife 的错误,但我不知道为什么。
我建议将 ButterKnife 更新到最新版本。
我还没有将我的项目迁移到 AndroidX,但是从 ButterKnife github 页面上的提交历史来看,最新的 9.0.x 版本似乎支持 AndroidX。
我在迁移到 androidx 时遇到了类似的问题。此问题是由于 Old Butter Knife 库依赖项引起的。
如果您使用的是黄油刀,那么您至少应该使用 9.0.0-SNAPSHOT 或更高版本的黄油刀。
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
我刚刚将我的项目迁移到 AndroidX。同步和构建阶段没问题,但是当我尝试 运行 时,编译器向我显示此错误:
error: package android.support.annotation does not exist
构建文件时出现此错误
// 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 属性
android.enableJetifier=true
android.useAndroidX=true
Butterknife 实施到 gradle
implementation "com.jakewharton:butterknife:8.8.1"
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"
IDE 表示 Files under the "build" folder are generated and should not be edited.
- Android Studio 3.2.1
- 最小 SDK 19,最大 SDK 28
- Gradle 版本 3.2.1
好像是 butterknife 的错误,但我不知道为什么。
我建议将 ButterKnife 更新到最新版本。
我还没有将我的项目迁移到 AndroidX,但是从 ButterKnife github 页面上的提交历史来看,最新的 9.0.x 版本似乎支持 AndroidX。
我在迁移到 androidx 时遇到了类似的问题。此问题是由于 Old Butter Knife 库依赖项引起的。
如果您使用的是黄油刀,那么您至少应该使用 9.0.0-SNAPSHOT 或更高版本的黄油刀。
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'