如何在android studio中获取build.gradle中的项目名称?

dzjeubhm  于 2023-01-02  发布在  Android
关注(0)|答案(1)|浏览(326)

如何获取android studiobuild.gradle的项目名称?

buildTypes {
    release {
        applicationVariants.all { variant ->
                    variant.outputs.each { output -> String projectName = project.name
            }
        }
    }
}
xxb16uws

xxb16uws1#

app-release.apk可以替换为您的项目名称.apk

buildTypes {
   release {
     applicationVariants.all { variant ->
       variant.outputs.each { output -> String projectName = getRootProject().name 
                                     output.outputFileName = projectName + ".apk"
    }
}

buildTypes {
   release {
     applicationVariants.all { variant ->
       variant.outputs.each { output -> 
                              output.outputFileName = getRootProject().name + ".apk"
    }
}

相关问题