android - Android Build Gradle尚未完成

标签 android android-studio gradle

had a problem运行android-studios build gradle,所以我测试了许多解决方案,但不幸的是我无法解决我的问题:
现在,我卸载旧的Android Studio和Android-sdk,然后下载包含默认SDK的android studio 1.5.1。
我安装了它们并创建了一个空项目,但是构建项目需要30分钟,我将添加此时间段内显示的对话框窗口。

最终创建了此错误的项目:

Error:(23, 17) Failed to resolve: junit:junit:4.12



请问有人可以帮我吗?
enter image description here

build.gradle文件内容:
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.armangar.app.fortest"
        minSdkVersion 23
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
}

最重要的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.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

最佳答案

testCompile是用于单元测试的配置(位于src / test中),而androidTestCompile用于测试api(位于src / androidTest中)。

两者的主要区别是test在常规Java JVM中运行,而androidTest测试在Android设备(或仿真器)上运行。

因此,使用

testCompile 'junit:junit:4.12'

代替
androidTestCompile 'junit:junit:4.12'

来源:http://tools.android.com/tech-docs/unit-testing-support

关于android - Android Build Gradle尚未完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35872739/

相关文章:

android - onCreateOptionsMenu 使用 fragment 多次命中

android - 如何从 Android 上保存的帐户中检索 Facebook-AuthToken

java - 如何使用 Java 字符串变量中的参数在 SQLite 数据库中创建新表?

android - Android Studio Tesseract OCR 应用程序运行时出现 Zygote 错误

gradle - 当从命令提示符运行时,为什么此Gradle exec命令失败?

jenkins - Gradle项目未在 Jenkins 下正确命名文件

gradle - gradle项目构建目录不存在

android - 无法在 Android Studio 中使用 Gradle 安装 Facebook Android SDK

Android Exoplayer : Get currentTime for a live stream

android - 更新后在 Android 2.3 中构建项目的问题。 'all com.android.support libraries must use the exact same version'