androidstudio同步的gradle无法正常工作 [英] androidstudio gradle sync not correctly works

查看:727
本文介绍了androidstudio同步的gradle无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有包含GSON-2.3.1.jar到我的gradle.build文件依赖性。但是,要同步它的时候给了我下面的错误。


  

错误:出现问题的项目配置:应用程序。


  
  

    

无法下载gson.jar(com.google code.gson:GSON:2.3.1)
    无法获取资源'的 https://jcenter.bintray.com/com/google/$c$c/gson/gson/2.3.1/g​​son-2.3.1.jar
    不能让' https://jcenter.bintray.com/com/google/$c$c/gson/gson/2.3.1/g​​son-2.3.1.jar
    连接 https://jcenter.bintray.com 拒绝


  

为什么它给了我这样的错误,为什么它寻找GSON。是我以前增加了。但随后从依赖关系列表中排除它。
这里是我的文件的gradle:

 应用插件:'com.android.application安卓{
    compileSdkVersion 23
    buildToolsVersion23.0.1    defaultConfig {
        的applicationIDaz.epul.myapplication
        15的minSdkVersion
        targetSdkVersion 23
        版本code 1
        的versionName1.0
    }
    buildTypes {
        发布 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
        }
    }
}
依赖{
    编译文件树(导演:'库',包括:['的* .jar'])
    编译com.android.support:appcompat-v7:23.0.1
    编译com.squareup.retrofit:改造:1.9.0
}

后来我发现,如果我要retrofit.jar添加到lib目录,然后将它添加到依赖关系上的build.gradle文件这样的方式=> 编译文件(库/改造-1.9.0.jar )它的工作原理,而是直接用编译加入'com.squareup.retrofit:改造:1.9.0不是作品


解决方案

试试你的依赖之前添加此块的build.gradle栏目

  {库
        jcenter()
    }

理论上这不应是必需的。但我面临类似的问题,而无需指定存储库。

I have not included gson-2.3.1.jar to my dependencies on gradle.build file. But it gives me below error when going to sync it.

Error:A problem occurred configuring project ':app'.

Could not download gson.jar (com.google.code.gson:gson:2.3.1) Could not get resource 'https://jcenter.bintray.com/com/google/code/gson/gson/2.3.1/gson-2.3.1.jar'. Could not GET 'https://jcenter.bintray.com/com/google/code/gson/gson/2.3.1/gson-2.3.1.jar'. Connection to https://jcenter.bintray.com refused

Why it gives me such error and why it looks for gson. Yes before i have added it. but then excluded it from dependencies list. Here is my gradle files:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "az.epul.myapplication"
        minSdkVersion 15
        targetSdkVersion 23
        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:23.0.1'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
}

What i noticed, if i am going to add retrofit.jar to lib and then adding it to dependencies on build.gradle file such way => compile files('libs/retrofit-1.9.0.jar') it works, but direct adding with compile 'com.squareup.retrofit:retrofit:1.9.0' not works

解决方案

Try adding this block before your dependencies section in build.gradle

repositories {
        jcenter()
    }

Theoretically this should not be required. But I have faced similar problems without specifying repository.

这篇关于androidstudio同步的gradle无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆