Ubuntu 14.04 Android 使用Maven二 创建自己的Maven工程
2014-04-30 14:22
477 查看
根据https://code.google.com/p/maven-android-plugin/wiki/GettingStarted 介绍,有两种方法可以创建Maven工程。
第一种方法是用archetype, 但是我使用了之后,发现archetype产生的项目编译时有一个依赖找不到,不管了,先换其他方法。
第二种方法就是使用android命令行创建项目,然后复制例子代码工程的pom文件并修改,
Ubuntu 14.04 设置Android开发环境 描述了如何用命令行创建项目
Ubuntu 14.04 Android 使用Maven一 使用例子工程介绍了例子工程helloflashlight
先创建一个项目mvn_example1
android create project --target android-10 --name mvn_example1 --path mvn_example1 --activity MainActivity --package org.csfreebird
Created project directory: mvn_example1
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/src/org/csfreebird
Added file mvn_example1/src/org/csfreebird/MainActivity.java
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/bin
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/libs
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res/values
Added file mvn_example1/res/values/strings.xml
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res/layout
Added file mvn_example1/res/layout/main.xml
Added file mvn_example1/AndroidManifest.xml
Added file mvn_example1/build.xml
Added file mvn_example1/proguard-project.txt
现在复制heelloflashlight的pom.xml文件到该项目目录下, 然后修改其中的一些配置: <groupId>org.freebird</groupId>
<artifactId>example1</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>mvn_example1</name>设置platform版本为10,这里使用的是API Level,也可以使用platform level: 2.3.3, 具体可以通过命令android list targets, 不过这里目前还只能设置16, 设置10部署会失败,暂时不明白原因。
删除掉ant相关的文件:mvn_example1$ rm -r bin build.xml build.properties libs
rm: cannot remove ‘build.properties’: No such file or directory
启动模拟设备后,运行下面的命令编译和部署:mvn clean install
mvn android:deploy
部署成功后,会看到模拟设备上出现程序图标。点击运行,成功。
第一种方法是用archetype, 但是我使用了之后,发现archetype产生的项目编译时有一个依赖找不到,不管了,先换其他方法。
第二种方法就是使用android命令行创建项目,然后复制例子代码工程的pom文件并修改,
Ubuntu 14.04 设置Android开发环境 描述了如何用命令行创建项目
Ubuntu 14.04 Android 使用Maven一 使用例子工程介绍了例子工程helloflashlight
先创建一个项目mvn_example1
android create project --target android-10 --name mvn_example1 --path mvn_example1 --activity MainActivity --package org.csfreebird
Created project directory: mvn_example1
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/src/org/csfreebird
Added file mvn_example1/src/org/csfreebird/MainActivity.java
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/bin
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/libs
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res/values
Added file mvn_example1/res/values/strings.xml
Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res/layout
Added file mvn_example1/res/layout/main.xml
Added file mvn_example1/AndroidManifest.xml
Added file mvn_example1/build.xml
Added file mvn_example1/proguard-project.txt
现在复制heelloflashlight的pom.xml文件到该项目目录下, 然后修改其中的一些配置: <groupId>org.freebird</groupId>
<artifactId>example1</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>mvn_example1</name>设置platform版本为10,这里使用的是API Level,也可以使用platform level: 2.3.3, 具体可以通过命令android list targets, 不过这里目前还只能设置16, 设置10部署会失败,暂时不明白原因。
<plugins> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <configuration> <sdk> <!-- platform as api level (api level 16 = platform 4.1)--> <platform>10</platform> </sdk> </configuration> </plugin> </plugins>
删除掉ant相关的文件:mvn_example1$ rm -r bin build.xml build.properties libs
rm: cannot remove ‘build.properties’: No such file or directory
启动模拟设备后,运行下面的命令编译和部署:mvn clean install
mvn android:deploy
部署成功后,会看到模拟设备上出现程序图标。点击运行,成功。
相关文章推荐
- Ubuntu 14.04 Android 使用Maven二 创建自己的Mavenproject
- 在Ubuntu上创建maven工程,编译器里一直不能正常使用maven工程
- Ubuntu 14.04 Android 使用Maven一个 用例project
- Ubuntu 14.04 Android 使用Maven一 使用例子工程
- ubuntu14.04 创建 android-studio 快捷启动方式
- 如何使用Android Studio把自己的Android library分享到jCenter和Maven Central
- 如何使用Android Studio把自己的Android library分享到jCenter和Maven Central
- Android N使用Ubuntu 14.04系统搭建编译环境
- android SQLite数据库使用总结之(二)创建自己的数据库
- Android之使用AlertDialog.Builder类创建带列表的对话框和带自己所布局视图的对话框
- eclipse创建的android maven工程使用ant编译,最后在studio里打开使用
- 如何使用Android Studio把自己的Android library分享到jCenter和Maven Central
- ubuntu14.04 给android 创建wifi
- Ubuntu 14.04下怎么使用chroot创建另外一个系统
- Android 创建自己的证书文件,使用signapk.jar为apk以及zip文件签名
- Ubuntu14.04使用virt-manager创建RHEL6.5镜像
- Android使用vitamio创建自己的播放器
- Android 系列 1.6使用Apache Maven创建“Hello,World”应用程序
- 使用vmware+ubuntu14.04编译android4.4.2源码
- maven的初步使用--Eclipse android maven的项目创建