Home  >  Article  >  Java  >  How to change the default name of APK in Android

How to change the default name of APK in Android

高洛峰
高洛峰Original
2017-02-07 16:07:541521browse

Android How to modify the default name of APK

The name generated when packaging the App with Android Studio defaults to app-release.apk (signed) or app-debug.apk (test version).

If you want to change the default name when packaging, you can open the build.gradle (module: app) file and add the following code in android{}:

android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
      def outputFile = output.outputFile
      if (outputFile != null && outputFile.name.endsWith('.apk')) {
        //这里修改apk文件名
        def fileName = outputFile.name.replace("app", "你想要的名字")
        output.outputFile = new File(outputFile.parent, fileName)
      }
    }
  }

Write Simply click BuildApk in the Build toolbar or use signature packaging.

The rendering is as follows:

Android 如何修改APK的默认名称

In fact, it can also be like this: right click -> Rename.

Thank you for reading, I hope it can help you, thank you for your support of this site!

For more Android related articles on how to change the default name of APK, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn