AndroidX 迁移后找不到符号 DataBindingComponent
Cannot find symbol DataBindingComponent after AndroidX migration
将我的整个项目迁移到 android x 后,我无法再编译它了。
我收到 100 个以下错误:
e: M:\tmp\EverywhereLauncher\app\generated\data_binding_base_class_source_out\devWithoutTestWithAccessibilityDebug\dataBindingGenBaseClassesDevWithoutTestWithAccessibilityDebug\out\com\my\app\databinding\ActivityMainBinding.java:52: error: cannot find symbol
@Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) {
^
symbol: class DataBindingComponent
location: class ActivityMainBinding
我不知道从哪里继续。
我现在有两个问题。
- 我只看到 100 个错误
- 所有错误都是一样的,可能隐藏了真正的错误
我尝试了什么:
我在我的项目中有以下内容 build.gradle
以将打印错误的数量增加到 10000:
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "10000"
}
}
这一直有效,但在这种情况下它不会增加打印的错误
知道我接下来可以做什么吗?
额外
我用下面的
android.enableJetifier=true
android.useAndroidX=true
我使用 android studio 3.2
,使用 kotlin 1.2.61
和 3.3.0-alpha01
gradle 构建工具
- 我使用
3.3.0-alpha01
gradle 构建工具,因为我也使用 evernote com.evernote:android-state
否则不会 - 问题在这里解释:https://github.com/evernote/android-state/issues/56
解决方案 - 增加记录的错误
过去,在 broject 的 build.gradle
文件中添加以下内容就足够了:
gradle.projectsEvaluated {
tasks.withType(JavaCompile.class) {
options.compilerArgs << "-Xmaxerrs" << "10000"
}
}
对于 kotlin,以下内容会有所帮助:
afterEvaluate {
if (project.plugins.hasPlugin("kotlin-kapt")) {
kapt {
javacOptions {
option("-Xmaxerrs", 10000)
}
}
}
}
真正的问题
在我的例子中,我将 class 从 java 转换为 kotlin,其中包含如下一些字段:
@Arg
Integer someValue;
转换器创建如下:
@Arg
internal var someValue: Int? = null
问题:
internal
不适用于注释,因此失败,但日志仅显示数据绑定错误...
示例项目build.gradle
https://gist.github.com/MFlisar/eca8ae6c2e6a619913ab05d503a4368f
我在更新到 androidx 后也遇到了这个错误,尝试了一些堆栈溢出帖子中建议的所有内容,最后更新到 gradle 插件 3.3.0-beta03 有效
将我的整个项目迁移到 android x 后,我无法再编译它了。
我收到 100 个以下错误:
e: M:\tmp\EverywhereLauncher\app\generated\data_binding_base_class_source_out\devWithoutTestWithAccessibilityDebug\dataBindingGenBaseClassesDevWithoutTestWithAccessibilityDebug\out\com\my\app\databinding\ActivityMainBinding.java:52: error: cannot find symbol
@Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) {
^
symbol: class DataBindingComponent
location: class ActivityMainBinding
我不知道从哪里继续。
我现在有两个问题。
- 我只看到 100 个错误
- 所有错误都是一样的,可能隐藏了真正的错误
我尝试了什么:
我在我的项目中有以下内容
build.gradle
以将打印错误的数量增加到 10000:gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs << "-Xmaxerrs" << "10000" } }
这一直有效,但在这种情况下它不会增加打印的错误
知道我接下来可以做什么吗?
额外
我用下面的
android.enableJetifier=true android.useAndroidX=true
我使用 android studio
3.2
,使用 kotlin1.2.61
和3.3.0-alpha01
gradle 构建工具- 我使用
3.3.0-alpha01
gradle 构建工具,因为我也使用 evernotecom.evernote:android-state
否则不会 - 问题在这里解释:https://github.com/evernote/android-state/issues/56
解决方案 - 增加记录的错误
过去,在 broject 的 build.gradle
文件中添加以下内容就足够了:
gradle.projectsEvaluated {
tasks.withType(JavaCompile.class) {
options.compilerArgs << "-Xmaxerrs" << "10000"
}
}
对于 kotlin,以下内容会有所帮助:
afterEvaluate {
if (project.plugins.hasPlugin("kotlin-kapt")) {
kapt {
javacOptions {
option("-Xmaxerrs", 10000)
}
}
}
}
真正的问题
在我的例子中,我将 class 从 java 转换为 kotlin,其中包含如下一些字段:
@Arg
Integer someValue;
转换器创建如下:
@Arg
internal var someValue: Int? = null
问题:
internal
不适用于注释,因此失败,但日志仅显示数据绑定错误...
示例项目build.gradle
https://gist.github.com/MFlisar/eca8ae6c2e6a619913ab05d503a4368f
我在更新到 androidx 后也遇到了这个错误,尝试了一些堆栈溢出帖子中建议的所有内容,最后更新到 gradle 插件 3.3.0-beta03 有效