Использование привязки данных Glide с kotlin не может найти символ

Я хочу привязать DataBinding в адаптере, есть ImageView. Я использую адаптер привязки Glide, но когда я тестирую на своем телефоне, не удается найти ошибки символа. И мне нужно попытаться перестроить проект, очистить проект, заново открыть студию Android. И измените ViewDataBinding на ItemGameNotReleasedBinding. но это все еще не работает. Может ли кто-нибудь помочь мне найти, где не так? Большое спасибо.

Сообщение об ошибке.

cannot find symbol

import com.perfowl.youli.databinding.ItemGameNotReleasedBindingImpl;

symbol: class ItemGameNotReleasedBindingImpl

location: package com.perfowl.youli.databinding

Файл build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.perfowl.youli"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 6
        versionName "1.0.6"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    dataBinding {
        enabled = true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.google.code.gson:gson:2.8.4'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.koushikdutta.ion:ion:2.2.1'
    implementation 'com.mikhaellopez:circularimageview:3.0.2'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'


    // Json
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.6'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.9.6'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.0'
    implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.6"


    // Rounded ImageView.
    implementation 'com.makeramen:roundedimageview:2.3.0'

    // Glide
    implementation ('com.github.bumptech.glide:glide:4.7.1') {
        exclude group: "com.android.support"
    }
    kapt 'com.github.bumptech.glide:compiler:4.7.1'

    // Kotlin data binding.
    kapt "androidx.databinding:databinding-compiler:3.3.0-alpha03"

    // Firebase Crashlytics
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }

    // U-meng analytics.
    implementation 'com.umeng.sdk:common:1.5.1'
    implementation 'com.umeng.sdk:analytics:7.5.3'

    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

это мой код ImageHelper.kr

package com.perfowl.youli.ui
import android.databinding.BindingAdapter
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.perfowl.youli.util.GlideApp

// Image binding
@BindingAdapter("android:src")
fun setSrc(view: ImageView, bitmap: Bitmap) {
    view.setImageBitmap(bitmap)
}

@BindingAdapter("android:src")
fun setSrc(view: ImageView, resId: Int) {
    view.setImageResource(resId)
}

@BindingAdapter("app:imageUrl", "app:placeHolder", "app:error")
fun loadImage(imageView: ImageView, url: String, holderDrawable: Drawable, errorDrawable: Drawable) {
    var requestOptions = RequestOptions()
    requestOptions = requestOptions.transforms(CenterCrop(), RoundedCorners(12))

    GlideApp.with(imageView.context)
            .load(url)
            .centerCrop()
            .apply(requestOptions)
            .into(imageView)
}

это код GameNotReleasedAdapter

@SuppressLint("InflateParams")
    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        var row = convertView
        val game = getItem(position)

        val binding: ViewDataBinding

        if (row == null) {
            row = inflater!!.inflate(R.layout.item_game_not_released, null)

            // Binding data
            binding =  DataBindingUtil.inflate(
                    LayoutInflater.from(parent.context),
                    itemLayoutId,
                    parent,
                    false
            )
        }else binding = DataBindingUtil.getBinding(convertView!!)!!

        binding.setVariable(variableId, game)

        platformIconLayout = row!!.findViewById(R.id.platform_LL)
        languageIconLayout = row.findViewById(R.id.language_LL)

//        nameTextView.text = game!!.name

//        glideUtil.loadImageWithGlide(game.cover, coverImageView)

        if (game.platform!!.size > 0) {
            setPlatformIcon(game.platform!!)
        }

        if (game.language!!.size > 0) {
            setLanguageIcon(game.language!!)
        }

        return binding.root
    }

Это код item_game_not_released.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">

    <data>

        <variable
            name = "game"
            type = "com.perfowl.youli.data.db.model.Game" />
    </data>

    <RelativeLayout
        android:layout_width = "match_parent"
        android:layout_height = "115dp"
        android:paddingLeft = "10dp"
        android:paddingRight = "10dp">

        <View
            android:id = "@+id/background"
            android:layout_width = "324dp"
            android:layout_height = "115dp"
            android:layout_alignParentEnd = "true"
            android:layout_alignParentRight = "true"
            android:background = "@drawable/bg_item_game" />

        <TextView
            android:id = "@+id/released_date"
            android:layout_width = "wrap_content"
            android:layout_height = "wrap_content"
            android:layout_alignParentEnd = "true"
            android:layout_alignParentRight = "true"
            android:layout_alignParentTop = "true"
            android:background = "@drawable/bg_date"
            android:lineSpacingMultiplier = "2.5"
            android:text = "@{game.releasedDate}"
            android:textColor = "@color/colorWhite"
            android:textSize = "13sp" />

        <ImageView
            android:id = "@+id/cover"
            android:layout_width = "141dp"
            android:layout_height = "80dp"
            android:layout_marginTop = "25dp"
            android:contentDescription = "@string/game_cover"
            app:imageUrl = "@{game.cover}" />


        <LinearLayout
            android:layout_width = "match_parent"
            android:layout_height = "match_parent"
            android:layout_alignBottom = "@id/cover"
            android:layout_alignTop = "@id/cover"
            android:layout_marginLeft = "5dp"
            android:layout_marginRight = "5dp"
            android:layout_toEndOf = "@id/cover"
            android:layout_toRightOf = "@id/cover"
            android:orientation = "vertical">

            <TextView
                android:id = "@+id/name"
                android:layout_width = "match_parent"
                android:layout_height = "0dp"
                android:layout_weight = "1"
                android:ellipsize = "end"
                android:maxLines = "2"
                android:text = "@{game.name}"
                android:textColor = "@color/colorTextPrimary"
                android:textSize = "14sp" />

            <LinearLayout
                android:id = "@+id/language_LL"
                android:layout_width = "wrap_content"
                android:layout_height = "wrap_content"
                android:orientation = "horizontal" />

        </LinearLayout>

        <LinearLayout
            android:id = "@+id/platform_LL"
            android:layout_width = "wrap_content"
            android:layout_height = "wrap_content"
            android:layout_alignBottom = "@id/background"
            android:layout_alignEnd = "@id/background"
            android:layout_alignRight = "@id/background"
            android:layout_marginBottom = "5dp"
            android:layout_marginEnd = "5dp"
            android:layout_marginRight = "5dp"
            android:orientation = "horizontal">

        </LinearLayout>

    </RelativeLayout>

</layout>

Вы должны объединить вашу строку и привязку накачки. Раздувайте привязку, используя идентификатор макета, который вы используете для строки, а затем установите для строки значение binding.root.

Vas 04.09.2018 21:37
2
1
1 148
0

Другие вопросы по теме