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

后端 未结 9 1757
遥遥无期
遥遥无期 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:04

    For Android Studio 3.1 this works for me:

    android {
         ...............
         ...............
    
         applicationVariants.all { variant ->
                changeAPKName(variant, defaultConfig)
            }
    
      compileOptions {
           sourceCompatibility JavaVersion.VERSION_1_8
           targetCompatibility JavaVersion.VERSION_1_8
           }
    
          .................................
          .................................
         }
    

    and

    def changeAPKName(variant, defaultConfig) {
        variant.outputs.all { output ->
            outputFileName = new File("xxxxx" + variant.versionName +".apk")
        }
    }
    

提交回复
热议问题