Create and compile Android applications using the command line

Source: Internet
Author: User

Android provides command line creation and compilation methods for comrades who do not like to use eclipse.

Create a project
android create project \--target <target_ID> \--name <your_project_name> \--path path/to/your/project \--activity <your_activity_name> \--package <your_package_namespace>

The following is an example.

android create  project --target 4 --name test --path test --activity testactivity --package com.dlmu2001.android

You can run the following command to obtain the ID of the currently available target.

android list targets


Reference http://developer.android.com/guide/developing/projects/projects-cmdline.html

Problem:

Error: Error parsing the SDK.
Error:/home/Tom/froyo/out/host/linux-x86/platforms is missing.
Error: Unable to parse SDK content.

Cause: If the SDK is not compiled, run these commands directly in the compiled Android source. You need to run these two commands in the SDK.


Create a project

The debug mode compilation can be automatically signed. You can execute ant debug.

The release mode is generated by default without a signature and cannot be installed. Run keytool to generate the keystore, modify build. Properities, and then compile the keystore and automatically sign it. Example:

keytool -genkey -alias test.keystore -keyalg RSA -validity 40000 -keystore test.keysotre

Add the following two sentences to build. properties:

key.store=/home/tom/android-sdk-linux_x86/exercise/test/test.keystorekey.alias=test.keystore

The first setting is the key storage location.

Compile:

ant release

Generate test-release.apk, in the bin directory

Reference: http://developer.android.com/guide/developing/building/building-cmdline.html#ManualReleaseMode

FAQs:

The android ant-based build system requires ant 1.8.0 or later. Current version is...

Solution: download the latest version to the website (http://ant.apache.org), decompress it to the user root directory, and then

cd /usr/sharemv ant ant_1.7mv ~/ant_1.8.2 ant

Then execute ant-version, which is 1.8.2.


Signature failed

Generally, the path is incorrect or the name is incorrect. Check whether the path is correct.


After compilation, use the ADB install command to install it to emulator or device.

If you want to overwrite the installation, add the-r Option



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.