" APP-release.apk"如何改变这个默认生成的apk文件名 [英] " app-release.apk" how to change this default generated apk name

查看:1059
本文介绍了" APP-release.apk"如何改变这个默认生成的apk文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我生成一个签名的APK android的工作室,默认情况下它给人的名字为app-release.apk ...

whenever i generate a signed apk in android studio,by default it gives the name as app-release.apk...

我们可以做任何设置,这样就应该及时,问我需要被分配到APK(它在Eclipse的方式做)

can we do any settings so that it should prompt and ask me the name which need to be assigned to the apk(the way it do in eclipse)

我做的是,重命名的apk它产生之后。 这不会给任何错误,但有没有真正的方式,让我可以做任何设置更改得到提示。

what i do is-rename the apk after it generated. This doesn't give any errors but is there any genuine way so that i can do any changes in settings to get a prompt.

请注意::

而生成APK安卓工作室是给我一个提示选择位置(只)

while generating apk android studio is giving me a prompt to select the location(only)

推荐答案

是的,我们可以更改,但有一些更多的关注

Yes we can change that but with some more attention

现在在添加此您的 build.gradle 在您的项目,同时确保你已经检查了建立变种项目的释放或调试 所以在这里我心中构建变量为发布,但你可能会因为调试选择为好。

Now add this in your build.gradle in your project while make sure you have checked the build variant of your project like release or Debug so here i have set my build variant as release but you may select as Debug as well .

    buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig getSigningConfig()
                applicationVariants.all { variant ->
                    variant.outputs.each { output ->
                        def date = new Date();
                        def formattedDate = date.format('yyyyMMddHHmmss')
                        output.outputFile = new File(output.outputFile.parent,
                                output.outputFile.name.replace("-release", "-" + formattedDate)
    //for Debug use output.outputFile = new File(output.outputFile.parent,
   //                             output.outputFile.name.replace("-debug", "-" + formattedDate)
                        )
                    }
                }
            }
        }

,不要忘记在运行项目之前同步的摇篮的 希望可以解决您的问题:)

and Don't forget to sync the gradle before running the projects Hope It will solve your problem :)

这篇关于" APP-release.apk"如何改变这个默认生成的apk文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆