Maven command to create an Android project

Source: Internet
Author: User

1. Create a project with the Android tool.

Android Create project \
--target <target_ID> \
--name <your_project_name> \
--path path/to/your/project \
--activity <your_activity_name> \
--package <your_package_namespace>
Target is the ' build target ' for your application. It corresponds to a Android platform library (including any add-ons, such as Google APIs) that's would like to build yo ur project against. To see a list of available targets and their corresponding IDs, execute:android list targets.
Name is the name of the for your project. This is optional. If provided, this name would be the used for your APK filename when you build your application.
Path is the location of the your project directory. If The directory does not exist, it is created for you.
Activity is the name of the your default activity class. This class file is created for inside<path_to_your_project>/src/<your_package_namespace_path>/. This would also is used for your apk filename unless you provide a name.
Package was the package namespace for your project, following the same rules as-packages in the Java programming Langua Ge.
For example: Create a name:myandroidmavenapp; Path:e:\app\myapp; Activity:mainactivity Package:com.example.mvnandroid's Android project.
Android Create Project
--target 1
--name Myandroidmavenapp
--path E:\app\myapp
--activity mainactivity
--package com.example.mvnandroid
Note: If the Android Home and Android tool is already configured in the system environment


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


[HTML]
<?xml version= "1.0" encoding= "UTF-8"?>
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
<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>

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<run>
<debug>true</debug>
</run>
<sdk>
<path>${env. Android_home}</path>
<platform>10</platform>
</sdk>
<emulator>
<avd>emulator-5554_android</avd>
</emulator>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
</plugins>
</build>
</project>

3. The project created in the command produced some files that were not needed when using Android Maven plugin.


Rm-r bin Build.xml build.properties Libs

4. Build the Project

To the root directory of the project Myandroidmavenapp:

MVN clean Install


Errors that may occur:

1. Failed to execute goal in Project Amvn_test:could not resolve dependencies for project Com.example.mvnandroid:amvn_te S
droid:jar:4.1 in Central (HTTP://REPO.MAVEN.APACHE.ORG/MAVEN2)


[HTML]
<span style= "White-space:pre" > </span><dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1</version>
<scope>provided</scope>
</dependency>
Reason: Dependency in Version = 4.1 is too high, not found. To be modified. 2.3.3 is possible.


1. Create the project:

MVN Archetype:create-dgroupid=com.mycompany.app-dartifactid=my-app

After the command executes you will see that MAVEN has generated a directory named My-app, which is the artifactid you specified in the command, and you will find the following standard project structure:

2.Build Project MVN Clean Compile
1. Enter on the command line: CD My-app Enter, enter under Project path
2. Enter MVN package return and the command line will print a variety of actions
Run a program
JAVA-CP Target/my-app-1.0-snapshot.jar com.mycompany.app.App

3. Run the Maven tool

Although it is difficult to list a very comprehensive table, here you can first list the most common default life cycle stages:

Validate: Verify that the project is correct and that all required resources are available.
Compile: Compile the source code for the project.
Test: Use the appropriate unit test framework for testing the compiled source code. These tests do not need to be packaged and deployed.
Package: Packages compiled code into a ready-to-publish format, such as a jar.
Integration-test: If necessary, package processing and publishing to an environment where integration testing is possible.
Verify: Run all checks to verify that the package is valid and meets quality standards.
Install: The package is installed in the local repository, can be used as a dependency of other projects.
Deploy: Execute in an integrated or release environment, copying the final version of the package to a remote repository, so that other developers or projects can be shared.
Clean: Clears the previously built artifacts (in Maven, the packages generated by the project are called artifact).
Site: Generates a document site for the project.


MVN Clean Dependency:copy-dependencies Package
This command clears the project first, then copies the dependencies, finally packages the project, and, of course, executes the previous phase of the phase before packaging. such as Compile,test.
Build site
MVN site
This phase generates project information based on the Pom.xml configuration. You can see the resulting document in the Target/site directory.


4. Package and run MVN clean packages

After the project is compiled and tested, the next important step is packaging. The package type is not specified in the Pom, and with the default package type jar, we can simply execute the command mvn the clean package. Similarly, MAVEN performs compile, test, and so on before packaging. Here we see that the Jar:jar task is responsible for packaging, which is actually the jar target of the jar plugin to package the project master code into a file named Hello-world-1.0-snapshot.jar, which is also located in the target/output directory. It is named according to Artifact-version.jar rules, and if necessary, we can also use Finalname to customize the name of the file, this is not expanded here, the book will be explained in detail later.


===========================================


MVN archetype:generate-darchetypeartifactid=android-quickstart-darchetypegroupid=de.akquinet.android.archetypes -darchetypeversion=1.0.8-dgroupid=com.study.android-dartifactid=a1


Command execution

{% highlight xml%}
MVN Clean Package

Packaged, but not deployed.
MVN clean Install

Package, deploy, and run.
MVN Clean Package Android:redeploy Android:run

This command is usually used for apps that are already installed on the phone, but the signatures are different, so we packaged and used the redeploy command to remove and redeploy the existing app, and finally run the app with the Run command.
MVN Android:redeploy Android:run

Do not package, redeploy and run the generated package.
MVN Android:deploy Android:run

Deploying and running a generated package, unlike redeploy, deploy does not delete existing deployment and application data.

MVN Clean install-prelease,channel-91

Packaged signature, the channel for channel-91 APK
{% Endhighlight%}

==================
So file processing:
 libvooleglib.so
    mvn install:install-file- Dgroupid=com.voole.vooleglib-dartifactid=libvooleglib-dversion=v1-dfile=d:\maven\bf\playproxylib\libs\armeabi\ libvooleglib.so-dpackaging=so-dgeneratepom=true-dclassifier=armeabi 
 
 libvooletoken.so
&NBSP;MVN install:install-file-dgroupid=com.voole.vooleglib-dartifactid=libvooletoken-dversion=v1-dfile=d:\ maven\bf\playproxylib\libs\armeabi\libvooletoken.so-dpackaging=so-dgeneratepom=true-dclassifier=armeabi 
 
 gifview.jar
mvn Install:install-file-dgroupid=com.voole.vooleglib-dartifactid=gifview- Dversion=1.0-dfile=d:\maven\bf\voolebf1.0\libs\gifview.jar-dpackaging=jar-dgeneratepom=true

Commons-codec-1.4.jar
MVN install:install-file-dgroupid=com.voole.vooleglib-dartifactid=common-codec-dversion=1.4-dfile=d:\maven\bf\ Voolebf1.0\libs\commons-codec-1.4.jar-dpackaging=jar-dgeneratepom=true


Alipay.jar
MVN install:install-file-dgroupid=com.voole.vooleglib-dartifactid=alipay-dversion=1.4-dfile=d:\maven\bf\ Voolebf1.0\libs\alipay.jar-dpackaging=jar-dgeneratepom=true

Universal-image-loader-1.9.3.jar
MVN Install:install-file-dgroupid=com.voole.vooleglib-dartifactid=universal-image-loader-dversion=1.9.3-dfile=d : \maven\bf\vooleframe\libs\universal-image-loader-1.9.3.jar-dpackaging=jar-dgeneratepom=true

Android-support-v4.jar
MVN Install:install-file-dgroupid=com.voole.vooleglib-dartifactid=android-support-v4-dversion=1.7.0_65-dfile=d : \maven\bf\vooleframe\libs\android-support-v4.jar-dpackaging=jar-dgeneratepom=true

Download the sample code that can be supplied to the package test http://blog.csdn.net/forever_crying/article/details/8455626

Download Https://github.com/simpligility/maven-android-sdk-deployer Address

Http://www.android100.org/html/201406/08/20945.html

Https://code.google.com/p/maven-android-plugin/wiki/GettingStarted Study Address






Maven command to create an Android project

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.