重命名UI基础测试.apk文件

时间:2018-07-10 05:06:19

标签: android android-gradle build.gradle android-espresso android-uiautomator

我要绑定基于UI的电话来控制BT相关功能。 实际上,基本的测试脚本和构建问题都已经完成。

在构建.apk文件(app-debug.apk / app-debug-androidTest.apk)之后,我想将应用程序名称更改(重命名)为“ Script.apk / Script-androidTest.apk”,但我没有不知道如何修改.apk文件的子修补程序。

现在,我可以通过将-debug单词替换为null来将“ app-debug.apk”的名称更改为“ script.apk”,但是我无法更改androidTest构建结果.apk文件(-debug-androidTest .apk)

下面是“ build.gradle”

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.uiautomatorexample"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        archivesBaseName = "UIA2Script"
        applicationVariants.all { variant ->
            variant.outputs.each { output ->
                def file = output.outputFile
                //def file2 = output.outputFile
                output.outputFile = new File(file.parent, file.name.replace("-debug",""))
            }
        }
    }
    /*repositories {
        maven { url 'http://repo1.maven.org/maven2'}
    }*/
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.debug
            minifyEnabled false
            proguardFile 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    androidTestCompile 'junit:junit:4.12'

    androidTestCompile 'com.android.support:support-v13:25.3.1'
    androidTestCompile 'com.android.support:support-annotations:25.3.1'
    androidTestCompile 'com.android.support.test:runner:0.5'
    //Set this dependency to us JUnit rules
    androidTestCompile 'com.android.support.test:rules:0.5'
    //Set this dependency to build and run Espresso tests
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    //Set this dependency to build and run UI Automator tests
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
}

0 个答案:

没有答案