创建一个android maven application
来源:互联网 发布:2k14导入2k15数据 编辑:程序博客网 时间:2024/04/29 15:34
出自: http://blog.csdn.net/luhuajcdd/article/details/8132386
手动的创建自己的android application
1.用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 an Android platform library (including any add-ons, such as Google APIs) that you would 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 defaultActivity
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 aname
.package
is the package namespace for your project, following the same rules as for packages in the Java programming language.
android create project --target 1 --name MyAndroidMavenApp --path E:\app\myapp --activity MainActivity --package com.example.mvnandroid
注意:前提已经在系统环境中配置android home 和 android tool
参考:http://blog.csdn.net/luhuajcdd/article/details/8132429
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.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.2.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>
3. 在命令中创建的项目生产了一些文件, 在用android maven plugin 的时候, 有些文件是不需要的。
rm -r bin build.xml build.properties libs
4.构建项目
到项目MyAndroidMavenApp 的根目录:
mvn clean install
可能出现的错误:
1. Failed to execute goal on project amvn_test: Could not resolve dependencies for project com.example.mvnandroid:amvn_tes
droid:jar:4.1 in central (http://repo.maven.apache.org/maven2) ->
<dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>4.1</version> <scope>provided</scope> </dependency>
原因:dependency中version = 4.1 太高了,没有找到。 要修改。2.3.3是可以的
注意:您的系统必须已经有mvn, 配置过环境变量
下载mvn:http://maven.apache.org/download.html
配置mvn 环境:http://www.cnblogs.com/smile2010/archive/2011/11/22/2259535.html
5.部署apk到连接的设备或模拟器上
mvn android:deploy
可以出现的错误:
No plugin found for prefix 'anroid' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\hlu\.m2\repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
解决方法:
在C:\Users\hlu\.m2\repository\settings.xml中增加如下配置
<pluginGroups> <!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup> --> <pluginGroup>com.jayway.maven.plugins.android.generation2</pluginGroup> </pluginGroups>
- 创建一个android maven application
- Android Application 创建全局变量
- Android Application 创建全局变量
- Android Application 创建全局变量
- xcode创建一个singleview application
- 创建一个maven项目
- 创建一个maven项目
- 创建一个较简单的 eclipse+android+maven 工程
- 创建一个较复杂的 eclipse+android+maven 工程
- 创建一个简单的 eclipse+android+maven 工程
- 创建一个适用于android工程的maven库
- 创建第一个android application
- android maven创建命令
- maven创建android项目
- Maven创建Android项目
- maven 学习笔记(二)创建一个简单的 eclipse+android+maven 工程
- maven 学习笔记(三)创建一个较复杂的 eclipse+android+maven 工程
- Xcode 6 如何创建一个Empty Application
- Ubuntu 10.04下gitolite的安装
- 著名的变量命名规则
- 伤感的QQ空间日志_爱情的动漫是你我的最爱
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in ..... 的处理方法
- android widget 使用------检测USB功能 .
- 创建一个android maven application
- JS正则表达式大全
- hdu 4444 Walk
- Java判断日期为昨天 今天 明天
- java内部类,内部类的共性,成员内部类,方法内部类匿名内部类,静态嵌套类,不解
- 局域网内mysql连接慢的解决办法
- 触屏网页设计初探2
- 打包jar
- sharepoint2010 删除失去AD账号的用户方法,代码方法