java - 迁移 AndroidX 运行错误 android.support.annotation 不存在
问题描述
我刚刚将我的项目迁移到 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
}
}
渐变属性
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.
- 安卓工作室 3.2.1
- 最小 SDK 19,最大 SDK 28
- Gradle 版本 3.2.1
这似乎是黄油刀的错误,但我不知道为什么。
解决方案
我建议将 ButterKnife 更新到最新版本。
我还没有将我的项目迁移到 AndroidX,但是从 ButterKnife github 页面上的提交历史来看,最新的 9.0.x 版本似乎支持 AndroidX。
推荐阅读
- ios - 如何使用现代 UICollectionViewDiffableDataSource 支持自定义单元格重新排序?
- mysql - 如何为cadence创建mysql数据库
- javascript - 如何使用 Apache Echarts 为多个系列设置工具提示标签?
- vector - 返回/移动生锈的 Vec/Field 并清空它的最有效方法是什么?
- javascript - 为什么循环属性不适用于我的第二个动画?
- git - 重命名一个 git 本地和远程分支后,这个仓库的其他用户应该怎么做?
- javascript - 承诺 {
使用 REST API 检索值时出错 - angular - 生成用于导出的角度包列表
- ios - 当我使用 ARWorldTrackingConfiguration 时,RealityKit 模型实体会更暗
- javascript - 为什么我需要添加 .isToggleOn?