Android: How to change specific name of the generated apk file in Android Studio?

后端 未结 9 1721
遥遥无期
遥遥无期 2020-12-29 08:44

By default IDE genarate a apk like app-debug.apk or app-release.apk file but I need to generate specific name of the Apk of the Ap

9条回答
  •  长发绾君心
    2020-12-29 09:03

    You can use this for app name with current date and version

    android {
    def version = "2.4";
    def milestone = "1";
    def build = "0";
    def name = getDate()+"APP NAME WHAT YOU WANT"+"v"+version
    
    
    signingConfigs {
        config {
           ….
       }
    }
    compileSdkVersion Integer.parseInt(COMPILE_SDK)
    buildToolsVersion BUILD_TOOLS_VERSION
    defaultConfig {
       applicationId "com.PACKAGENAME"
       minSdkVersion Integer.parseInt(MIN_SDK_LIBRARY)
       targetSdkVersion Integer.parseInt(TARGET_SDK)
       versionCode 11
       versionName "2.3"
       multiDexEnabled true
    }
    buildTypes {
       debug {
           applicationVariants.all { variant ->
               variant.outputs.each { output ->
                   def apk = output.outputFile;
                   def newName;
                   newName = apk.name.replace("-" + variant.buildType.name, "")
                           .replace(project.name, name);
                   newName = newName.replace("-", "-" + version + "-" + milestone +
                           "-" + build + "-");
                   output.outputFile = new File(apk.parentFile, newName);
               }
           }
       }
    

提交回复
热议问题