1

I made a very hello world with Android Studio NDK. As instructed from http://tools.android.com/tech-docs/new-build-system/gradle-experimental, I copied exactly the same (left only some newer build tool version), but the error always appears: Error:(49, 1) A problem occurred evaluating project ':app'.

Could not find method testCompile() for arguments [junit:junit:4.12] on project ':app'.

Could you tell me what's problem with my HelloWorld? Here's my app 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'
}

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

and 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
J.J.
  • 1,128
  • 2
  • 23
  • 62
Cuong Phan
  • 311
  • 1
  • 4
  • 8

1 Answers1

0

AFAIK, android plugin doesn't have a testCompile configuration, which is one from gradle's java plugin, but has an androidTestCompile. So, you have to rename it in your dependencies, as:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
}
Stanislav
  • 27,441
  • 9
  • 87
  • 82
  • The same error, Stanislav. Then it say could not found androidTestCompile. I add android plugin version 1.3.1 with gradle 2.5 then it said could not find com.android.model.application. Do you have any idea about this? Thanks and best regards, – Cuong Phan Nov 29 '15 at 06:00
  • @CuongPhan android plugin is not the same as experemental, I suppose. To use experimental you have to apply the exactly plugin you have in question above. Could you try not to include test dependencies to check, whether is it ok, without jUnit now.? – Stanislav Nov 29 '15 at 06:35
  • @CuongPhan I've looked into examples on github, but found no test dependencies fpr app project. No really sure, how it can be done. Alternatively you may try to apply java plugin and then you'll have ability to provide testCompile configuration, but not really sure, that it's a right way to handle this. – Stanislav Nov 29 '15 at 06:42