【问题标题】:I have some errors in gradle sync - android我在 gradle 同步中有一些错误 - android
【发布时间】:2016-07-09 21:24:21
【问题描述】:

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

首先我给出了这个错误:

连接超时:连接。如果您使用 HTTP 代理,请 在 IDE 或 Gradle 中配置代理设置。

我在google上搜索,发现必须在全局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(模块: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')
}

【问题讨论】:

标签: android android-gradle-plugin


【解决方案1】:

解决办法

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

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


包含一个 JAR 文件

我发现我必须手动下载预期的文件并将其添加到android studio,但我不知道我必须下载什么文件?

错误提示你下载com.android.databinding:dataBinder(任何版本)

从哪里来?

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

如何添加到android studio?

因为你的 build.gradle 中有这个

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

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

【讨论】:

  • 我下载了文件:dataBinder-1.0-rc4.jar 并移到了我的项目库文件夹:workspace/test/app/libs/ .但再次给我同样的错误:No cached version Listing for com.android.databinding:dataBinder:1.+ available for offline mode.。甚至我在我的模块文件夹 (Material-Animations-master) 中创建了一个名为 libs 的文件夹,并将该文件复制到该文件夹​​中。但再次给我同样的错误!我必须在哪里复制这个文件?
  • 在与build.gradlesrc/ 相同的模块(目录)中,您应该创建libs/ 目录。如果你确实把它放在那里,那么你应该能够退出离线模式并删除上面写着classpath "com.android.databinding:dataBinder:1.+"的行
  • 我的问题没有解决。你能通过团队查看器连接到我的电脑并检查我的问题吗?
  • 可以通过 teamviewer 连接,但我正在工作,所以我确定这不是一个好主意。您说您将 libs 文件夹添加到 Material Animations 模块中。为什么?那是一个库,我假设你是从 GIthub 克隆的?除非您向其中添加功能,否则您根本不应该接触这些文件。
  • 好的,我只将文件添加到 app/libs 文件夹而不是库文件夹,但再次给我同样的错误:( - 你有电报吗?如果你有请联系我。用户名:Dash_saeid
猜你喜欢
  • 1970-01-01
  • 2015-03-02
  • 2018-04-27
  • 1970-01-01
  • 1970-01-01
  • 2017-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多