I am beginner in Gradle Android Tests and I've found some problems when I try launch my test.
This is my 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.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
def codeGradiantLicenseControlJavaCommon = '../../code/common'
sourceSets {
main {
java.srcDir codeGradiantLicenseControlJavaCommon
}
}
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
abortOnError false
}
}
sourceSets {
androidTest {
java.srcDir file('src/androidTest/java')
}
}
configurations {
androidtTestCompile.extendsFrom runtime
androidtTestRuntime.extendsFrom androidtTestCompile
}
dependencies {
androidtTestCompile files("$project.buildDir/classes/release")
}
dependencies {
compile 'com.android.support:appcompat-v7:23.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:23.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
// Optional -- UI testing with Espresso
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
// Optional -- UI testing with UI Automator
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
//Mockito
androidTestCompile "org.mockito:mockito-core:1.+"
}
task createJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('build/libs/')
include('classes.jar')
rename ('classes.jar', 'GradiantLicenseControl.jar')
}
task androidTest(group: "verification", type: Test) {
systemProperty "java.library.path", "src/androidTest/jniLibs"
testClassesDir = sourceSets.androidTest.output.classesDir
classpath = sourceSets.androidTest.runtimeClasspath
androidTest.reports.html.destination = file("$buildDir/reports/androidTest")
}
And in Editor everything looks good, but when I execute gradle adroiTest
not recognizes classes I'd imported:
Incremental java compilation is an incubating feature.
:library:compileAndroidTestJava
/Users/eutelobarreiro/Software/license-manager/projects/java/GradiantLicenseControlAndroid/library/src/androidTest/java/org/gradiant/license/control/GradiantLicenseControlNoLicenseTest.java:3: error: package android.content does not exist
import android.content.Context;
What is wrong in my build.gradle?
Thanks
Aucun commentaire:
Enregistrer un commentaire