Android studio生成APK打包,修改生成APK的路径和名字

在app的build.gradle的android添加输出时候的路径和名字

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    //对生成的apk文件的名字和路径改到其他地方
    android.applicationVariants.all { variant ->
        variant.outputs.all {
            variant.getPackageApplication().outputDirectory = new File("D:/AndroidStudioProjects/Learning/EasyTest/app/src/main/assets/plugins")
            outputFileName = "test.jar"

        }
    }
}

"D:/../app/src/main/assets/plugins"表示编译生成的apk的输出路径
 outputFileName = "test.jar" 表示编译生成的apk的文件的名字

当然这样的命名不太规范。但是直观啊哈哈哈 :)

猜你喜欢

转载自blog.csdn.net/qq_25066049/article/details/83384373