gpt4 book ai didi

android - 我无法设置 Android 数据绑定(bind)

转载 作者:太空狗 更新时间:2023-10-29 13:15:50 24 4
gpt4 key购买 nike

我的根 build.gradle 文件中有这个:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

并在应用 build.gradle 文件中:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.company.app"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.0'
//more third-party libraries
}

这是我的布局:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<data>

<variable
name="user"
type="com.company.app.models.LoginCredentials"/>
</data>

<EditText
android:layout_width="match_parent"
android:layout_height="55dp"
android:text="@{user.username}"/>

<!-- More layouts and widgets -->
</layout>

但是我得到这个错误:

Error:(82, 35) No resource type specified (at 'text' with value '@{user.username}').

我试过:

dataBinding { 
enabled = true
}

但我得到了另一个错误:

Error:Could not find com.android.databinding:library:1.0-rc3.

我该怎么办?我刚刚将 Android Studio 更新到 v1.5.1。

最佳答案

实际上是 compileSdkVersion 21 创建问题。您需要使用 UPGRADED 版本。

你应该使用

compileSdkVersion 23 
buildToolsVersion "23.0.1"

&

targetSdkVersion 23  

您需要包含 dataBinding.enabled = true

关于android - 我无法设置 Android 数据绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34784441/

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