gpt4 book ai didi

android - 找不到 com.android.databinding :compiler. 3.4.0

转载 作者:行者123 更新时间:2023-12-02 13:05:41 24 4
gpt4 key购买 nike

大家好,我们如何在 android_plugin_version = '3.4.0' 中启用数据绑定(bind)?作为我的 android studio,我安装了最新版本,并且在将 android_plugin_version = '3.4.0' 降级到 3.2.xx 时收到另一个错误。

项目毕业

buildscript {
ext {
kotlin_version = '1.3.31'
android_plugin_version = '3.4.0'
}
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath "com.android.tools.build:gradle:$android_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

模块
 apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 28
defaultConfig {
applicationId "xxx.xxx.com"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}

kapt {
generateStubs = true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'

kapt "com.android.databinding:compiler:$android_plugin_version"
}

同步没有问题,但是运行时,我收到了这个错误
Could not find com.android.databinding:compiler:3.4.0.
Searched in the following locations:

-

https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.4.0/compiler-3.4.0.pom
- https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.4.0/compiler-3.4.0.jar
- https://jcenter.bintray.com/com/android/databinding/compiler/3.4.0/compiler-3.4.0.pom
- https://jcenter.bintray.com/com/android/databinding/compiler/3.4.0/compiler-3.4.0.jar
- https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.4.0/compiler-3.4.0.pom
- https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.4.0/compiler-3.4.0.jar

最佳答案

您使用了错误版本的数据绑定(bind)编译器。对于最新版本,您可以查看 mvnrepository 等网站.目前最新版本是 3.4.0。
在这里,您传递了错误的版本:

 kapt "com.android.databinding:compiler:$android_plugin_version"

相反,使用这个:
kapt "com.android.databinding:compiler:3.4.0"

更新

在 Android Studio 3.3 及更高版本中,您不需要添加注释处理器 kapt "com.android.databinding:compiler:$android_plugin_version" .只需设置 dataBinding.enabled = true在您的模块 gradle 文件中或像这样:
android {
...
dataBinding {
enabled = true
}
}

关于android - 找不到 com.android.databinding :compiler. 3.4.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55979206/

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