Android Studio 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
}
此处为app / 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}">
...
答案 0 :(得分:1)
尝试删除<import type="java.lang.Boolean" />
。如果您已从java.lang
导入了任何软件包,则由于已经自动导入,因此没有必要。