我在gradle sync中有一些错误 - android

时间:2016-03-22 19:43:41

标签: android android-gradle

我有android studio v1.4并且在gradle sync中有一些错误。

首先我给出了这个错误:

  

连接超时:连接。如果你是HTTP代理的后面,请   在IDE或Gradle中配置代理设置。

我在谷歌搜索,发现我必须在全局gradle设置中打开离线工作

之后我给出了这个错误:

  

com.android.databinding没有缓存版本列表:dataBinder:1。+   可用于离线模式。

为了解决这个问题,我发现我必须手动下载目标文件并将其添加到android studio。

但我不确切知道我必须下载哪个文件?从哪里来?以及如何添加到android studio?

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.+"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

build.gradle(module:app)

apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.example.saeid7laptop.test"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    maven {
        url "https://jitpack.io"
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile project(':Material-Animations-master')
}

1 个答案:

答案 0 :(得分:1)

解决方案

问题最终由Android Studio中的代理设置解决。这些可以在“首选项”窗口中找到,它看起来像这样。

This post也作为解决方案提供。

proxy prefs

包含JAR文件

  

我发现我必须手动下载目标文件并将其添加到android studio,但我不确切知道我必须下载哪个文件?

错误告诉您下载com.android.databinding:dataBinder(任何版本)

  

从哪里来?

以下是JCenter的最新版本。只需使用页面中间右侧的“文件”链接下载JAR文件即可。

  

如何添加到android studio?

因为您在build.gradle

中有这个
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

只需将JAR文件移动到您需要使用DataBinding库的模块的libs/文件夹中。