摇篮无法解决Android Studio中的依赖 [英] Gradle cannot resolve dependencies in Android Studio

查看:1874
本文介绍了摇篮无法解决Android Studio中的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的深化发展与3的同事,最近,我们的项目不能再基于Android Studio中的一个Android应用程序。我们每个人都有不同的Andr​​oid版本工作室(我的是0.2.8),并将其编译失败的他们。我们是不是能找到什么原因造成的问题,因为它发生在我们所有人的不同时刻(奇怪的是,同一个项目的版本,应用程序是建立在我的Andr​​oid工作室,而不是我的同事之一)。

有时,Android的工作室是能够编译我的项目时,它会打开它,但后来当我试图运行应用程序失败。但大多数时候,Android的工作室失败,当它打开它来编译我的项目。

我没有得到任何错误,以帮助我理解这个问题,只有后台任务的邮件的标题可以给我发生了什么事的一个暗示:摇篮:解决依赖':_DebugApk。这个后台任务无法完成,它只是加载,直到时间的尽头。

我不知道这是否是有关的build.gradle文件,但在这里它是你能找到的东西错案。

 首页= System.getenv(ANDROID_HOME)buildscript {
    库{
        mavenCentral()
    }
    依赖{
        类路径'com.android.tools.build:gradle:0.5.+
    }
}
应用插件:'机器人'库{
    mavenCentral()
    行家{
        网址http://maven.hq.couchbase.com/nexus/content/repositories/releases/
    }    行家{
        网址http://files.couchbase.com/maven2/
    }
}依赖{
    编译com.android.support:support-v4:18.0.+
    编译com.android.support:appcompat-v7:18.0.+
    编译com.google.android.gms:播放服务:3.1.36
    编译文件树(导演:'库',包括:的* .jar)
    编译com.couchbase.cblite:CBLite:1.0.0-β
    编译com.couchbase.cblite:CBLiteEktorp:1.0.0-β
    编译com.couchbase.cblite:CBLiteJavascript:1.0.0-β    instrumentTestCompile'c​​om.jayway.android.robotium:robotium独奏:4.3
}安卓{
    compileSdkVersion 18
    buildToolsVersion18.1    sourceSets {
        主要{
            manifest.srcFile'的Andr​​oidManifest.xml
            java.srcDirs = ['src'中]
            resources.srcDirs = ['src'中]
            aidl.srcDirs = ['src'中]
            renderscript.srcDirs = ['src'中]
            res.srcDirs = ['水库']
            assets.srcDirs = ['资产']
        }        //移动测试,测试/ JAVA,测试/ RES等...
        instrumentTest.setRoot(测试)
        //移动构建类型构建类型/<&型GT;
        //例如,建立类型/调试/ JAVA,内置类型/调试/ AndroidManifest.xml中,...
        //这个动作出来在src / LT他们默认位置和的;类型> / ...这将
        //与SRC /冲突正在使用的主要来源集。
        //添加新的构建类型或产品的口味应该陪同
        //通过类似定制。
        debug.setRoot(集结类型/调试)
        release.setRoot(集结类型/释放)
    }
}tasks.withType(编译){
    options.encoding =UTF-8
}

什么是解决相关性问题时,Android的工作室在做什么?哪些原因会导致它挂这个样子?

编辑:

在执行构建的gradle --info ,它给了我以下错误:


  

失败:建立失败,一个异常


  
  


      
  • 出了什么问题:执行失败的任务:compileDebug。


      
      

        

    找不到系统的Java编译器。确保已安装了JDK(不仅仅是JRE)并配置JAVA_HOME系统变量
        指向根据目录。


  •     


  

编辑2:

Android的工作室停止能够重新编译我的项目。现在,它停在摇篮:解决依赖':_ReleaseApk。当我尝试通过命令行来的gradle编译,它的工作没有任何错误...

编辑3:

再次Android的工作室是在编译我的项目失败。现在,它停在摇篮:解决依赖':_DebugCompile。当我尝试通过命令行来的gradle编译,它的工作没有任何错误......上帝我讨厌摇篮!


解决方案

添加JAVA_HOME变量后,我能够编译我的应用程序像往常一样。

编辑:

在我得到了另一个错误(见问题EDIT 2),我只是删除了我的项目的生成文件夹,并再次合作。

编辑2:

据停止再次合作(见问题编辑3)

I am developping an Android application on Android Studio with 3 collegues and recently, our project cannot be built anymore. We all have different versions of Android Studio (mine is 0.2.8) and it fails to compile on all of them. We aren't able to find what is causing the problem because it happened at different moments for all of us (strangely, with the same project version, the app was building on my Android Studio and not on the one of my collegues).

Sometimes, Android Studio is able to compile my project when it opens it, but then fails when I try to run the app. But most of the time, Android Studio fails to compile my project when it opens it.

I get no error to help me understand the problem, only the message title of the background task can give me a hint of what is happening : Gradle: Resolve dependencies ':_DebugApk'. This background task never finishes, it just load until the end of time.

I don't know if it is related to the build.gradle file, but here it is in case you can find something wrong.

home = System.getenv("ANDROID_HOME")

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
    maven {
        url "http://maven.hq.couchbase.com/nexus/content/repositories/releases/"
    }

    maven {
        url "http://files.couchbase.com/maven2/"
    }
}

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.android.support:appcompat-v7:18.0.+'
    compile 'com.google.android.gms:play-services:3.1.36'
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.couchbase.cblite:CBLite:1.0.0-beta'
    compile 'com.couchbase.cblite:CBLiteEktorp:1.0.0-beta'
    compile 'com.couchbase.cblite:CBLiteJavascript:1.0.0-beta'

    instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.3'
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')




        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

tasks.withType(Compile) {
    options.encoding = 'UTF-8'
}

What is Android Studio doing when resolving dependencies? What can cause it to hang like this?

EDIT:

When executing gradle build --info, it gives me the following error :

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileDebug'.

    Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.

EDIT 2:

Android Studio stopped being able to compile my project again. Now it stops at Gradle: Resolve dependencies ':_ReleaseApk'. And when I try to compile with gradle via command line, it works without any error...

EDIT 3:

Again, Android Studio is failing at compiling my project. Now it stops at Gradle: Resolve dependencies ':_DebugCompile'. And when I try to compile with gradle via command line, it works without any error... God I hate Gradle!

解决方案

After adding the JAVA_HOME variable, I was able to compile my application like usual.

EDIT:

After I got the another error (see EDIT 2 on the question), I just deleted the build folder of my project and it worked again.

EDIT 2:

It stopped working again (see EDIT 3 on the question)

这篇关于摇篮无法解决Android Studio中的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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