Android 单元测试的gradle配置

单元测试能在android studio中能编译通过,则gradle要进行相应的配置,以下利用一个示例来说明相关配置项。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion BUILD_TOOL_VERSION
    //useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.evideostb.kdroid.app.******"
        minSdkVersion 21
        targetSdkVersion 22
        versionCode getSvnRevision()
        versionName "1.0"
        //配置单元测试第一步
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        debug {
            //******
        }
        release.initWith(android.signingConfigs.debug)
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            signingConfig signingConfigs.debug
        }
    }
}

afterEvaluate {
    //******
}

repositories {
    flatDir {
        dirs rootSrcDir + 'modules_bin/trunk/aar'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    //配置单元测试第二步:下面这个包必须存在,但是要根据你android studio环境对版本进行修改
    compile 'com.android.support:appcompat-v7:22.0.0'
    //配置单元测试第三步:下面三行必须添加,
    androidTestCompile 'com.android.support.test:runner:0.2'
    androidTestCompile 'com.android.support.test:rules:0.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'

    compile fileTree(include: ['*.jar'], dir: rootSrcDir + 'modules_bin/trunk/jar')
    compile(name:'middleware', ext:'aar')
   compile CBBSHIP
    compile IJKPLAYER
}

你可能感兴趣的:(Android 单元测试的gradle配置)