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

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

    Step 1: Go to root of the main project, under app , right click on app and refactor the app into specific name (example iPlanter) and press ok

    Step 2: Go to Project Setting file which is setting.gradle file

    setting.gradle file contains

    include ':app'
    

    Now need to replace app by specific name.

    For Example app replace by iPlanter in include ':app' it looks like below

    include ':iPlanter'
    

    then Sync project, after that run your application. Finally, App generate an apk like iPlanter-debug.apk or iPlanter-release.apk file.

    0 讨论(0)
  • 2020-12-29 09:18

    On my PC, it suffices to rename (through refactor) app to the desired name yourName. After that, include ':app' in setting.grandle file is changed to include ':yourName'. However, in my case I need to close/reopen Android Studio because of sync error. As a result, obtain apk something like yourName-debug.apk and yourName-release.apk.

    0 讨论(0)
  • 2020-12-29 09:30

    This will help you. This code will create app name like iPlanter-release.apk or iPlanter-debug.apk

    buildTypes {
       applicationVariants.all { variant ->
        variant.outputs.each { output ->
            project.ext { appName = 'iPlanter' }
            def newName = output.outputFile.name
            newName = newName.replace("app-", "$project.ext.appName-")
            output.outputFile = new File(output.outputFile.parent, newName)
         }
      }
    

    }

    0 讨论(0)
提交回复
热议问题