1.使用命令行新建一个Android项目
[email protected] test$ android create project --targetandroid-14 --namewirelessqa --path/Volumes/warehouse/test/wirelessqa --activityMyActivity --packagecom.wirelessqa.android
Android命令创建项目的格式:
android create project \--target <target_ID> \--name <your_project_name> \--path path/to/your/project \--activity <your_activity_name> \ --package <your_package_namespace>
2. 建新一个pom.xml文件
<?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.bixiaopeng.android</groupId> <artifactId>wireless-android</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>apk</packaging> <name>bixiaopeng</name> <dependencies> <dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>4.1.1.4</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.6.0</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>
老毕的Blog: http://blog.csdn.net/wirelessqa/article/details/14057041
3. 删除多余的文件
有可能在你创建项目的时候多出一些文件,删除一下
rm -r bin build.xml build.properties libs
4. 执行 mvn clean install
注意:依赖插件的版本需要注意一下,如果命令失败需要改一下插件版本。
[email protected] wirelessqa$ mvn clean install -X…………..省略N多 [INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 4.854s[INFO] Finished at: Sat Nov 02 15:40:30 CST 2013[INFO] Final Memory: 20M/81M[INFO] ————————————————————————————————————