在Android Studio中生成apk名称作为包名称

Ban*_*ram 7 android apk android-studio android-gradle-plugin package-name

Android studio将生成默认的apk名称为app-(release | debug).apk.
如何生成apk文件名与app的包名一样com.example-debug.apk.

Gab*_*tti 16

您可以在不使用其他任务的情况下进行设置archivesBaseName.

例如:

 defaultConfig {
      ....
      project.ext.set("archivesBaseName", "MyName-" + defaultConfig.versionName);

  }
Run Code Online (Sandbox Code Playgroud)

输出:

MyName-1.0.12-release.apk
Run Code Online (Sandbox Code Playgroud)

在你的情况下:

project.ext.set("archivesBaseName", "com.example" );
Run Code Online (Sandbox Code Playgroud)


sle*_*dav 4

尝试将其放入模块的 build.gradle 中

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def file = output.outputFile
        def appId = android.defaultConfig.applicationId
        def fileName = appId + "-" variant.buildType.name +".apk"
        output.outputFile = new File(file.parent, fileName)
    }
}
Run Code Online (Sandbox Code Playgroud)