gpt4 book ai didi

android - 在 Android Studio 3.3 Canary 3 Kotlin 项目上找不到符号 DataBindingComponent

转载 作者:太空宇宙 更新时间:2023-11-03 10:58:23 25 4
gpt4 key购买 nike

我刚刚在启用了 Kotlin 的 Android Studio 3.3 Canary 3 上创建了一个新项目。然后我还启用了数据绑定(bind),但我收到一条错误消息,提示找不到 DataBindingComponent 类。

这是我的gradle文件

buildscript {
apply from: 'versions.gradle'
addRepos(repositories)
dependencies {
classpath deps.android_gradle_plugin
classpath deps.kotlin.plugin
classpath deps.kotlin.allopen
classpath deps.navigation.safe_args_plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
repositories {
google()
}
}

allprojects {
addRepos(repositories)
}


task clean(type: Delete) {
delete rootProject.buildDir
}

我的模块 gradle 文件:

 apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

apply plugin: 'androidx.navigation.safeargs'


android {
compileSdkVersion build_versions.target_sdk
buildToolsVersion build_versions.build_tools
defaultConfig {
applicationId "arca.advanced.mg.com.myapplication"
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation deps.support.app_compat
implementation deps.support.recyclerview
implementation deps.support.cardview
implementation deps.support.design
implementation deps.support.legacy
implementation deps.navigation.fragment_ktx
implementation deps.room.runtime
implementation deps.lifecycle.runtime
implementation deps.lifecycle.extensions
implementation deps.lifecycle.java8
implementation deps.retrofit.runtime
implementation deps.retrofit.gson
implementation deps.glide.runtime

implementation deps.dagger.runtime
implementation deps.dagger.android
implementation deps.dagger.android_support
implementation deps.constraint_layout
implementation deps.kotlin.stdlib

implementation deps.timber
implementation deps.rx.java
implementation deps.rx.android

kapt deps.dagger.android_support_compiler
kapt deps.dagger.compiler
kapt deps.room.compiler
kapt deps.lifecycle.compiler
}

我的 fragment 文件

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">

<data>

<variable
name="viewModel"
type="arca.advanced.mg.com.arca.ui.splash.SplashViewModel" />

</data>


<RelativeLayout
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>

</layout>

这是我的错误

enter image description here

最佳答案

我认为这是 kapt 冲突。

如果可能,请尝试关闭 Dagger,并像这样检查 Room 中的错误:

Fields annotated with @Relation cannot be constructor parameters. These values are fetched after the object is constructed.

Cannot find setter for field.

Cannot figure out how to save this field into database.

如果没有帮助,请尝试将 libs 与 kapt 的库一一关闭,并仔细检查错误日志。

检查./gradlew app:dependencies传递依赖,可能是androidx的问题。

同时检查 gradlew app:dependencies --configuration kapt 也许你会发现一些可疑的东西

关于android - 在 Android Studio 3.3 Canary 3 Kotlin 项目上找不到符号 DataBindingComponent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51590106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com