1

我用 Android Studio NDK 创造了一个非常好的世界。按照http://tools.android.com/tech-docs/new-build-system/gradle-experimental的指示,我复制了完全相同的内容(只留下了一些较新的构建工具版本),但总是出现错误:错误: (49, 1) 评估项目 ':app' 时出现问题。

在项目“:app”上找不到参数 [junit:junit:4.12] 的方法 testCompile()。

你能告诉我我的 HelloWorld 有什么问题吗?这是我的应用程序 build.gradle

 apply plugin: "com.android.model.application"

model {
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"

        defaultConfig.with {
            applicationId = "com.android.services.testjni"
            minSdkVersion.apiLevel = 15
            targetSdkVersion.apiLevel = 23
            versionCode = 1
            versionName = "1.0"
            buildConfigFields.with {
                create() {
                    type = "int"
                    name = "VALUE"
                    value = "1"
                }

            }
        }
        android.buildTypes {
            release {
                minifyEnabled = false
                proguardFiles.add(file("proguard-rules.pro"))
            }
        }
        android.productFlavors {
            create("flavor1") {
                applicationId = "com.app"
            }
        }
        // Configures source set directory.
        android.sources {
            main {
                java {
                    source {
                        srcDir "src"
                    }
                }
            }
        }
    }
}

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

和 build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle-experimental:0.2.1"

        // 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
}

和 gradle-wrapper.properties

#Fri Nov 27 17:00:16 ICT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
4

1 回答 1

0

AFAIK,android 插件没有testCompile配置,它来自 gradle 的java插件,但有一个androidTestCompile. 因此,您必须在依赖项中将其重命名为:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
}
于 2015-11-29T04:12:13.550 回答