简体   繁体   English

我在gradle同步中有一些错误-Android

[英]I have some errors in gradle sync - android

I have android studio v1.4 and have some errors in gradle sync. 我有android studio v1.4,并且在gradle同步中有一些错误。

in first I gave this Error: 首先我给了这个错误:

Connection timed out: connect. 连接超时:连接。 If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle. 如果您使用HTTP代理,请在IDE或Gradle中配置代理设置。

I searched in google and found that I must turn on offline work in global gradle settings 我在Google中搜索,发现必须在全局Gradle设置中打开离线工作

after that I gave this Error: 之后,我给出了这个错误:

No cached version listing for com.android.databinding:dataBinder:1.+ available for offline mode. 离线模式下没有com.android.databinding:dataBinder:1. +的缓存版本列表。

for solving this I found that I must manual download the intended file and add it to android studio. 为了解决这个问题,我发现我必须手动下载所需的文件并将其添加到android studio中。

but I dont know exactly what file I must download ? 但是我不知道我必须下载什么文件? and from where ? 从哪里来的? and how add to android studio ? 以及如何添加到android studio中?

build.gradle(project: test) : 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) : build.gradle(模块: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')
}

The solution 解决方案

The problem ended up being solved by the proxy settings in Android Studio. 该问题最终由Android Studio中的代理设置解决。 Those can be found in the Preferences window and it looks like this. 这些可以在“首选项”窗口中找到,看起来像这样。

This post was also provided as a solution. 该帖子也作为解决方案提供。

代理偏好


To include a JAR file 包括一个JAR文件

I found that I must manual download the intended file and add it to android studio, but I dont know exactly what file I must download? 我发现必须手动下载所需的文件并将其添加到android studio中,但是我不知道我必须下载哪个文件?

The error tells you to download com.android.databinding:dataBinder (any version) 该错误告诉您下载com.android.databinding:dataBinder (任何版本)

and from where? 从哪里来的?

Here is the latest version on JCenter . 这是JCenter上的最新版本。 Just download the JAR file using the "Files" link towards the middle-right of the page. 只需使用页面右上角的“文件”链接下载JAR文件。

how add to android studio ? 如何添加到android studio?

Since you have this in your build.gradle 由于您在build.gradle有此

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

Just move the JAR file into the libs/ folder of the module you need to use the DataBinding library in. 只需将JAR文件移动到使用DataBinding库所需的模块的libs/文件夹中即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM