Jua*_*dez 22 data-binding android gradle android-databinding
我正在浏览https://developer.android.com/tools/data-binding/guide.html上的Android数据绑定指南.我已经确定我正在运行Android Studio 1.3(金丝雀版).
遵循指南,我收到此错误:
Gradle sync failed: could not find com.android.databinding:library:1.0-rc0
Run Code Online (Sandbox Code Playgroud)
还有其他人有同样的问题吗?谢谢你的帮助.
App build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
classpath "com.android.databinding:dataBinder:1.0-rc0"
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
模块build.graddle
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
apply plugin: 'android-apt'
def AAVersion = '3.3'
def MyProject = 'com.commonsware.android.frw.filesdemo'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
repositories {
mavenCentral()
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName "$MyProject"
}
}
android {
compileSdkVersion 22
buildToolsVersion "22"
defaultConfig {
applicationId "$MyProject"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions{
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
}
dexOptions {
preDexLibraries = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile "com.squareup:otto:1.3.6"
compile "commons-io:commons-io:+"
compile 'com.fasterxml.jackson.jr:jackson-jr-all:2.5.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
Run Code Online (Sandbox Code Playgroud)
Dat*_*ham 16
我有这个问题并通过在我的顶级build.gradle中的allprojects.repositories下添加"jcenter"来解决它(我一直在使用mavenCentral).
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.databinding:dataBinder:1.0-rc1'
}
}
allprojects {
repositories {
mavenCentral()
jcenter() // <=== *** Adding this fixed it ***
}
}
Run Code Online (Sandbox Code Playgroud)
我在同步build.gradle文件时遇到错误.
错误:无法解析:com.android.databinding:library:1.0-rc0
错误:无法解析:com.android.databinding:adapters:1.0-rc0
我终于找到了解决方案.
dependencies {
// instead of the below pathes...
//classpath "com.android.tools.build:gradle:1.3.0-beta2"
//classpath "com.android.databinding:dataBinder:1.0-rc0"
// I used the following classpathes.... It works!
classpath "com.android.tools.build:gradle:1.3.+"
classpath "com.android.databinding:dataBinder:1.+"
}
Run Code Online (Sandbox Code Playgroud)
通过查看您的错误,Gradle couldn't find com.android.databinding:dataBinder:1.0-rc0您应该尝试这样做,
classpath "com.android.databinding:dataBinder:1.0-rc1"
Run Code Online (Sandbox Code Playgroud)
要使用,请
DataBinding遵循所有这些步骤.
Android Studio的Android Studio 1.3版本.要设置您application的使用data binding,data
binding请top-level build.gradle在"android"下面添加到文件的类路径.
dependencies {
classpath "com.android.tools.build:gradle:1.3"
classpath "com.android.databinding:dataBinder:1.0-rc1"
}
Run Code Online (Sandbox Code Playgroud)然后确保jcenter位于顶级build.gradle文件中的项目的存储库列表中.
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)在你想要使用数据绑定的每个模块中,在android插件之后立即应用插件.
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
Run Code Online (Sandbox Code Playgroud)Clean和build你的应用程序.
完整的代码
top-level build.gradle 文件,
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3'
classpath "com.android.databinding:dataBinder:1.0-rc1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
module-level build.gradle 文件,
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.packagename"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
Run Code Online (Sandbox Code Playgroud)
有关详细数据绑定指南.
对于完整的演示数据绑定Android
小智 1
请尝试将类路径更改为“com.android.tools.build:gradle:1.3.0-beta 2 ”并设置buildToolsVersion“ 23 rc2 ”。
执行此操作之前,请不要忘记通过 SDK 管理器更新 SDK 包。
您可以在此处找到有关 Android Preview SDK 的更多信息:设置 Preview SDK
| 归档时间: |
|
| 查看次数: |
20585 次 |
| 最近记录: |