Use ant to automatically publish Android APK

Source: Internet
Author: User

When publishing an APK is a burden, you must enter the automation mode.

This article uses ant for compilation, signature, alignment, and release.

1 download sun-java6-jdk

Refer to here for download.

Export java_home =/usr/lib/JVM/Java-6-sun

 

2. Generate ant build. XML for an existing project

Run the command line to the root directory of the current project and run the following command:

android update project --path .

You can use the ant command to view related information and help, as shown below:

$ ant $ ant debug

If you need proguard, turn off the debuggable in androidmanifest. xml. (when you look up the information, you find that the gap between Chinese and foreign countries is too large. The Chinese version of this article is still a long term ).

3 shipment! Shipment! Script:

#!/bin/bashAPP_NAME="StandardLauncher"CD="."RELEASE_APP=$CD/bin/$APP_NAME-release-signed.apkRELEASE_DIR=~/released_apks/standardLauncherPWD="xxx"#ant releaseecho "Sign apk..."cp $CD/bin/$APP_NAME-release-unsigned.apk $RELEASE_APP"$JAVA_BIN/jarsigner" -keystore "my-release-key.keystore" -storepass $PWD -keypass $PWD $RELEASE_APP "my-release-key"echo "Verigy apk...""$JAVA_BIN/jarsigner" -verify $RELEASE_APPversionName=$(aapt d badging $RELEASE_APP |grep versionName= | cut -d "=" -f4 | cut -d "'" -f2)echo "Get versionName = $versionName"echo "zipalign apk..."zipalign -f 4 $RELEASE_APP "$RELEASE_APP"_alignedcp "$RELEASE_APP"_aligned $RELEASE_DIR/"$APP_NAME"_V"$versionName"_build_$(date +%Y%m%d).apkecho "Clean up..."rm -v $RELEASE_APPrm -v "$RELEASE_APP"_alignedcd $RELEASE_DIR$RELEASE_DIR/cleanup.sh

The command to obtain the version name in the middle of PS needs to be improved.

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.