Android Studio 卡在“Gradle:解决依赖关系 '_debugCompile'"上或“分离配置1" [英] Android Studio stuck on "Gradle: resolve dependencies '_debugCompile'" or 'detachedConfiguration1'

查看:34
本文介绍了Android Studio 卡在“Gradle:解决依赖关系 '_debugCompile'"上或“分离配置1"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我在我的项目中做了什么更改,但是在构建 gradle 脚本时突然无法通过这一步.

I have no idea what I changed in my project, but it suddenly cannot get past this step while building gradle scripts.

仅使用gradle assemble"构建它没有问题.

之前的卡点是解决依赖关系detachedConfiguration1".(在 _debugCompile 第一次尝试失败后,我又回到了 detachedConfiguration1).我猜是依赖项目太多了?我的一些示例项目在 Studio 中导入得很好....我重新安装了 Android Studio 并删除了所有设置和首选项.

the previous stuck point was resolve dependencies 'detachedConfiguration1'. (After the first failed attempt of _debugCompile, I'm back at detachedConfiguration1). I guess it is too many dependency projects? Some sample projects I have are imported just fine in the Studio.... I reinstalled the Android Studio and removed all the settings and preferences as well.

每次它开始这样做时我都必须杀死它.

I have to kill it every time it starts doing this.

按响铃吗?

import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryPlugin

// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript {
repositories {
    mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:0.9.+'
}

apply plugin: 'android'

repositories {
    maven { url 'http://ksoap2-android.googlecode.com/svn/m2-repo' }

    mavenCentral()
}

dependencies {

    compile 'com.google.code.ksoap2-android:ksoap2-android:2.5.2'
    compile 'com.android.support:support-v4:18.0.+'
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':lib-projects:StickyListHeaders')
    compile project(':lib-projects:ActionBar-PullToRefresh')
    compile project(':lib-projects:facebook')
    compile project(':lib-projects:Mopub:mopub-sdk')
    compile project(':lib-projects:NineOldAndroids')
    compile project(':lib-projects:ActionBarSherlock:actionbarsherlock')
    compile project(':lib-projects:ActionBarSherlock:actionbarsherlock-i18n')
    compile project(':lib-projects:SmoothProgressBar')
    compile project(':lib-projects:android-viewflow-master:viewflow')
}

android {

    signingConfigs {

        debug {
            storeFile file('....')
        }
    }

    compileSdkVersion 19
    buildToolsVersion "19.0.3"
    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')

    }
}

推荐答案

自从我切换到 Android Studio 以来,我经常遇到这个问题.这确实是存储库无法访问的问题 - 要么是由于网络问题,要么更可能是存储库因任何原因关闭.

I've encountered this problem far too frequently since i switched over to Android Studio. This is indeed an issue with the repository not being accessible - either due to a network issue or, more likely, the repo being down for whatever reason.

我发现的最简单的解决方法是在 Android Studio 首选项中选择离线工作"模式.如果您需要添加新的依赖项,这无济于事,但如果您已经添加了所有依赖项,它就可以解决问题.

The simplest work-around that I've found is to just select the "work offline" mode within the Android Studio preferences. This doesn't help if you need to add a new dependency, but if you already have all your dependencies added it does the trick.

要启用此设置,请转到:

To enable this setting go to:

首选项 -> Gradle

Preferences -> Gradle

在右侧选项中,转到全局分级设置"并选中离线工作"框.

In the right side options go down to "Global Gradel Settings" and check the "Offline work" box.

该框应如下所示:

您可以定期取消选中此框以查看存储库是否重新上线.

You can periodically uncheck this box to see if the repo is back online.

注意:此选项等效于在从命令行运行 gradle 构建时设置 --offline 标志.

NOTE: This option is the equivalent of setting the --offline flag when running a gradle build from the command line.

这篇关于Android Studio 卡在“Gradle:解决依赖关系 '_debugCompile'"上或“分离配置1"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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