[Android] build Android app based on Linux command line (ii): Command line Administration Project

Source: Internet
Author: User

Create an Android project

The Android tool is required to create an Android project on the command line (the tool is provided by the Android SDK, located in the <sdk>/tools/directory. )。 It automatically generates a project directory that contains several default application files, filed files, configuration files, and a build file.

command usage [1]:

$ android Create project \<target_ID> \<your_project_name> \--path path/to/your/project \<your_activity_name> \<your_package_namespace>

  Target: build goals. The Android platform library that the application applies to (including add-on, such as Google API). Use the Android list targets command to see all available targets and their IDs.

  Name: project name (optional). If this option is provided, the name value will be used as the build result. apk file name.

   Path: The project path. If it does not exist, it will be created automatically.

  activity: The default Activity class name. The corresponding class file is created under the <path_to_your_project>/src/<your_package_namespace_path>/ directory. If the name value is not provided, the activity value is used as the build result. apk file name.

  Package : The package namespace is the same as the package rule in Java programming.

Once the project has been built, you can develop Android. If you want, you can move the project directory anywhere else [2]. You can also select an Android project as a third-party library project, but it will only be available to other projects as a shared resource, and cannot be installed on Android devices.

Update Project

When you replace a new development environment, you can use the Android Update Project command to update your project so that it adapts to the new environment. You can also use this command to update the project's build target (--target) and project name (--name). The Android tool will automatically upgrade or create the files needed for the update.

Command usage:

$ android Update Project--name <project_name>--target <target_ID>--path <path_to_ Your_project>

  Target : build the target.

  Path : the project path.

  Name : Optional, if you do not want to update the project name, you can omit the option. )

For example:

$ android Update Project--name MyApp--target 2--path ./myappproject

Referencing library files

If you want to reference a third-party library, you can simply add a third-party library index to the project's build properties.

Command usage:

$ android Update project \<target_ID> \--pathpath/to/your/   Path/to/library_projecta

The above command includes a third-party library by updating the build properties. What it does is actually add a android.library.reference to the Project.Properties file. N property.

android.library.reference.1=Path/to/library_projecta

If you want to add multiple third-party libraries, you can manually edit the Project.Properties file according to their relative priority, using the . N exponent to represent their respective priorities. For example:

android.library.reference.1=path/to/library_projectaandroid. library.reference.2=Path /to/library_projectbandroid. library.reference.3=Path/TO/LIBRARY_PROJECTC

Or you want to set LIBRARY_PROJECTC to the highest priority:

android.library.reference.2=path/to/library_projectaandroid. library.reference.3=Path /to/library_projectbandroid. library.reference.1=Path/TO/LIBRARY_PROJECTC

where the . N exponent is a continuous natural number starting from 1, and if there is a break in the middle, subsequent references are ignored.

At build time, these third-party libraries merge with the application one by one, from low to high priority. Third-party libraries cannot make reference merges with other libraries themselves, and they are isolated from each other before they are merged into the application.

Note:

[1] If you do not want to enter the Android SDK directory every time to run the Android command, you can add the SDK platform-tools/and tools/two directories to the environment variable PATH.

[2] Try not to change the project path as much as possible, as this will break the SDK path properties in Local.properties. If you changed the project path, use the Android Update Project command to update the project's SDK location.

Report:

1. [Android Developer] managing Projects from the Command line

[Android] build Android app based on Linux command line (ii): Command line Administration Project

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.