lundi 12 septembre 2016

Cannot resolve RoboElectric

I am stuck at this instruction:

Building with Gradle Add the following to your build.gradle:

testCompile "org.robolectric:robolectric:3.1.2"

Annotate your test with the Gradle test runner:

@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class)
public class SandwichTest 
{

}

Note that you must specify the constants field which points to the BuildConfig.class generated by the build system. Robolectric uses the constants in the class to compute the output paths used by Gradle when building your project. Without these values, Robolectric will not be able to find your merged manifest, resources, or assets.

If I did this and reference RoboElectric, the IDE complains since it cannot resolve this:

@RunWith(RobolectricGradleTestRunner.class)

Here is my gradle build file:

apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "com.neonapps.android.notifire"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "0.0.1"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.android.support:multidex:1.0.1'

    androidTestCompile "com.google.dexmaker:dexmaker:1.2"
    androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
    androidTestCompile 'com.android.support:support-annotations:24.2.0'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test:rules:0.5'
    androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
    testCompile "org.robolectric:robolectric:3.1.2"

    compile('com.mikepenz:materialdrawer:5.3.6@aar') {
        transitive = true
    }
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:gridlayout-v7:24.2.0'
    compile 'com.android.support:cardview-v7:24.2.0'
    compile 'com.android.support:recyclerview-v7:24.2.0'
    compile 'com.code-troopers.betterpickers:library:3.0.0'
    compile 'joda-time:joda-time:2.3'
    compile 'com.jakewharton:butterknife:8.3.0'
    apt 'com.jakewharton:butterknife-compiler:8.3.0'
}

Any ideas? It is very basic instruction in building with Gradle but its tremendous hassle to run RoboElectric.

Aucun commentaire:

Enregistrer un commentaire