android - 更新到 com.android.tools.build:gradle:3.4.1 -> jRuntimeException: android.databinding.tool.util.LoggedErrorException: 发现数据绑定错误
问题描述
安卓工作室 3.4.1。
在我的 build.gradle android 项目中:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.ANDROIDX_TEST = '1.2.0-alpha05'
ext.ESPRESSO_VERSION = '3.2.0-alpha02'
ext.KOTLIN_VERSION = '1.3.40'
ext.KOTLIN_COROUTINE_VERSION = '1.2.1'
ext.RETROFIT_VERSION = '2.6.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这里应用程序/build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation('com.crashlytics.sdk.android:crashlytics:2.7.0@aar') { transitive = true; }
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0-alpha04'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha06'
implementation 'com.android.support:design:28.0.0'
implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
implementation "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
implementation 'com.yuyh.json:jsonviewer:1.0.6'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha01'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$KOTLIN_COROUTINE_VERSION"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINE_VERSION"
implementation project(':common')
androidTestCompile 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'
// Espresso framework
androidTestImplementation "androidx.test.espresso:espresso-core:$ESPRESSO_VERSION"
androidTestImplementation "androidx.test.espresso:espresso-intents:$ESPRESSO_VERSION"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$ESPRESSO_VERSION"
androidTestImplementation "androidx.test:rules:$ANDROIDX_TEST"
androidTestImplementation "androidx.test:runner:$ANDROIDX_TEST"
// UI Automator framework
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.0'
testImplementation 'junit:junit:4.12'
}
和项目成功构建和运行。但是更新到之后:
classpath 'com.android.tools.build:gradle:3.4.1'
我在构建时遇到错误:
java.lang.RuntimeException: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
****/ data binding error ****msg:Missing import expression although it is registered
file:D:\dev\myproject\android\MP\app\src\main\res\layout\wallet_list_item.xml
****\ data binding error ****
****/ data binding error ****msg:Missing import expression although it is registered
file:D:\dev\myproject\android\MP\app\src\main\res\layout\trader_list_item.xml
****\ data binding error ****
****/ data binding error ****msg:Missing import expression although it is registered
file:D:\dev\myproject\android\MP\app\src\main\res\layout\trader_details_activity.xml
****\ data binding error ****
****/ data binding error ****msg:Missing import expression although it is registered
file:D:\dev\myproject\android\MP\app\src\main\res\layout\wallet_details_activity.xml
****\ data binding error ****
at com.sun.tools.javac.main.Main.compile(Main.java:553)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
这里wallet_list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="java.lang.Boolean" />
<import type="com.myprojecttm.android.util.CommonUtil" />
<variable
name="handler"
type="com.myprojecttm.android.ui.adapter.WalletListItemAdapter" />
<variable
name="item"
type="com.myprojecttm.android.model.Wallet" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/walletContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{() -> handler.onClickItemDetails(item)}"
app:inTrade="@{item.inTrade}">
...
解决方案
尝试删除<import type="java.lang.Boolean" />
. 如果您从 导入了任何包java.lang
,则不需要,因为它已经自动导入。
推荐阅读
- c# - 图像缩放后绘制图形对象
- android - 无法在 WebView 上加载数据
- android - 右侧和文本上方带有向下图标的选取器 - Android
- java - 匈牙利算法 - 当某些“工作”对某些工人不可用时该怎么办?
- julia - 有效地使用 Plots.jl 动画子图
- haskell - 在 GHCI 中设置自定义提示会导致标准类型出现大量错误消息
- haskell - 可能使用唯一数据类型的 Int 表达式
- javascript - 有没有办法将包含日期的字符串数组从服务器端传递到客户端?
- angular - 重置多个字段后如何只发送一个请求?
- javascript - 如何使用 javascript 将文件上传到 GCS?