Android Stdio How to customize the build apk name

Source: Internet
Author: User

Android stdio automatically generated by default the name of the app is App-release or App-debug, after the build and manually change the name of the APK, it is very troublesome.

How to customize the name of the APK: Add the following to the \app\build.gradle file

Apply plugin: ' Com.android.application 'def getTime () {return NewDate (). Format ("YyyyMMdd", Timezone.getdefault ());} Android {compilesdkversion22buildtoolsversion"25.0.2"Defaultconfig {ApplicationID"Com.example.myapplication"minsdkversion19targetsdkversion22Versioncode1Versionname"1.0"} buildtypes {release {minifyenabledfalseproguardfiles Getdefaultproguardfile (' Proguard-android.txt '), ' Proguard-rules.pro '        }    }    //app name after packagingApplicationvariants.all {variant-Variant.outputs.each {Output-def OutputFile=output.outputfile def fileNameif(OutputFile! =NULL&& outputFile.name.endsWith ('. apk '))) {                if(Variant.buildType.name.equals (' release ')) ) {FileName= "Loverheart_release${defaultconfig.versionname}.${gettime ()}.apk"                } Else if(Variant.buildType.name.equals (' Debug ') ) {FileName= "Loverheart_debug${defaultconfig.versionname}.${gettime ()}.apk"} output.outputfile=NewFile (Outputfile.parent, FileName)}} }}dependencies {Compile filetree (dir:' Libs ', include: [' *.jar ']) Testcompile' junit:junit:4.12 'Compile' com.android.support:appcompat-v7:22.2.1 'Compile' com.android.support:design:22.2.1 '}

The generated APK package is named: loverheart_release1.0.20170417.apk

Android Stdio How to customize the build apk name

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.