" APP-release.apk"如何改变这个默认生成的apk文件名

" 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 :)