DataBinding问题 - 错误找不到符号

问题描述 投票:0回答:2

我有数据绑定的问题,我试图在Fragment中运行它

FragmentUserProfileEditMain:

class FragmentUserProfileEditMain : Fragment(), ViewStateUserProfileEditMain {
   lateinit var binding: FragmentUserProfileEditMainBinding
   override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
        }

        override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
             binding = DataBindingUtil.inflate(
                inflater, R.layout.fragment_user_profile_edit_main, container, false)
            return binding.getRoot()
        }

摇篮:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28
    dataBinding {
        enabled = true
    }
   .....
}
dependencies {
    def dagger_version = "2.18"
    def support_version = '1.0.0-beta01'
    def arch_version = '2.0.0-alpha1'
    ...
    //Google Arch
    implementation "androidx.lifecycle:lifecycle-extensions:$arch_version"
    kapt "androidx.lifecycle:lifecycle-compiler:$arch_version"
    implementation "androidx.room:room-runtime:$arch_version"
    kapt "androidx.room:room-compiler:$arch_version"
    kapt "androidx.databinding:databinding-compiler:3.3.2"

    implementation 'android.arch.navigation:navigation-fragment:1.0.0-rc02'
    ......
    }

fragment_user_profile_edit_main.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>
        ...
    </data>
    <ScrollView

            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent"
                                                           android:layout_height="wrap_content">
    ...

class FragmentUserProfileEditMainBinding已生成,但编译器显示错误:

D:\Android\cod\app\build\generated\source\kapt\debug\ru\test\data\DataBinderMapperImpl.java:18: error: cannot find symbol
import ru.ohmypeer.peers.databinding.FragmentUserProfileEditMainBindingImpl;
                                    ^
  symbol:   class FragmentUserProfileEditMainBindingImpl
  location: package ru.test.data.databinding

我试着打开,关闭Android工作室。清除/重建项目,使缓存/重新启动无效

android data-binding
2个回答
1
投票

这是我的错,我尝试从数据设置layout_height


0
投票

只是因为其他人有这个问题,并在搜索中找到此页面。对我来说问题是我从另一个视图复制了一个布局,忘了删除对另一个视图的viewmodel的引用。

© www.soinside.com 2019 - 2024. All rights reserved.