Create an android maven application

Source: Internet
Author: User

1. Use android tool to create a project.

Android create project \
-- Target <target_ID> \
-- Name <your_project_name> \
-- Path/to/your/project \
-- Activity <your_activity_name> \
-- Package <your_package_namespace>
Target is the "build target" for your application. it corresponds to an Android platform library (including any add-ons, such as Google APIs) that you wowould like to build your project against. to see a list of available targets and their corresponding IDs, execute: android list targets.
Name is the name for your project. This is optional. If provided, this name will be used for your. apk filename when you build your application.
Path is the location of your project directory. If the directory does not exist, it will be created for you.
Activity is the name for your default Activity class. this class file will be created for you inside <path_to_your_project>/src/<your_package_namespace_path> /. this will also be used for your. apk filename unless you provide a name.
Package is the package namespace for your project, following the same rules as for packages in the Java programming language.
For example, create an android project named name: MyAndroidMavenApp; path: E: \ app \ myapp; activity: MainActivity package: com. example. mvnandroid.
Android create project
-- Target 1
-- Name MyAndroidMavenApp
-- Path E: \ app \ myapp
-- Activity MainActivity
-- Package com. example. mvnandroid
Note: If you have configured android home and android tool in the system environment

2. Create a pom. xml file in the project root directory,

<? Xml version = "1.0" encoding = "UTF-8"?>
<Project xmlns = "" xmlns: xsi = "" xsi: schemaLocation = "">
<ModelVersion> 4.0.0 </modelVersion>
<GroupId> com. example. mvnandroid </groupId>
<ArtifactId> amvn_test </artifactId>
<Version> 1.0.0-SNAPSHOT </version>
<Packaging> apk </packaging>
<Name> amvn_t </name>
<GroupId> com. google. android </groupId>
<ArtifactId> android </artifactId>
<Version> 2.3.3 </version>
<Scope> provided </scope>
<FinalName >$ {project. artifactId} </finalName>
<SourceDirectory> src </sourceDirectory>
<GroupId> com. jayway. maven. plugins. android. generation2 </groupId>
<ArtifactId> android-maven-plugin </artifactId>
<Version> 3.2.0 </version>
<Extensions> true </extensions>
<GroupId> com. jayway. maven. plugins. android. generation2 </groupId>
<ArtifactId> android-maven-plugin </artifactId>
<Debug> true </debug>
<Path >$ {env. ANDROID_HOME} </path>
<Platform> 10 </platform>
<Avd> emulator-5554_android </avd>
<UndeployBeforeDeploy> true </undeployBeforeDeploy>

3. The project created in the command produces some files. Some files are not required when android maven plugin is used.

Rm-r bin build. xml build. properties libs

4. Build a project

Go to the root directory of the Project MyAndroidMavenApp:

Mvn clean install

Possible errors:

1. Failed to execute goal on project amvn_test: cocould not resolve dependencies for project com. example. mvnandroid: amvn_tes
Droid: jar: 4.1 in central (>

<Span style = "white-space: pre"> </span> <dependency>
<GroupId> com. google. android </groupId>
<ArtifactId> android </artifactId>
<Version> 4.1 </version>
<Scope> provided </scope>
Cause: version = 4.1 is too high in dependency and cannot be found. To modify. 2.3.3 is acceptable

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: 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.