обновить до com.android.tools.build:gradle:3.4.1 -> jRuntimeException: android.databinding.tool.util.LoggedErrorException: обнаружены ошибки привязки данных - PullRequest
1 голос
/ 28 июня 2019

Android Studio 3.4.1.

В моем проекте Android в build.gradle:

// 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}">
...

1 Ответ

1 голос
/ 28 июня 2019

Попробуйте удалить <import type="java.lang.Boolean" />. Если вы импортировали какие-либо пакеты из java.lang, в этом нет необходимости, поскольку они уже импортированы автоматически.

...