依据https://code.google.com/p/maven-android-plugin/wiki/GettingStarted介绍,有两种方法能够创建Mavenproject。

第一种方法是用archetype, 可是我使用了之后,发现archetype产生的项目编译时有一个依赖找不到,无论了,先换其它方法。

另外一种方法就是使用android命令行创建项目,然后复制样例代码project的pom文件并改动,

Ubuntu 14.04 设置Android开发环境描写叙述了怎样用命令行创建项目

Ubuntu 14.04 Android 使用Maven一 使用样例project介绍了样例projecthelloflashlight


先创建一个项目mvn_example1

android create project --target android-10 --name mvn_example1 --path mvn_example1 --activity MainActivity --package org.csfreebirdCreated project directory: mvn_example1Created directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/src/org/csfreebirdAdded file mvn_example1/src/org/csfreebird/MainActivity.javaCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/resCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/binCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/libsCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res/valuesAdded file mvn_example1/res/values/strings.xmlCreated directory /home/dean/work/gitlab_cloud/android/example/mvn_example1/res/layoutAdded file mvn_example1/res/layout/main.xmlAdded file mvn_example1/AndroidManifest.xmlAdded file mvn_example1/build.xmlAdded 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 libsrm: cannot remove ‘build.properties’: No such file or directory

启动模拟设备后,执行以下的命令编译和部署:

mvn clean installmvn android:deploy

部署成功后,会看到模拟设备上出现程序图标。

点击执行,成功。




更多相关文章

  1. Android 完全退出当前应用程序的四种正确方法
  2. Android NFS 文件系统
  3. Handler 使用方法详解
  4. 在eclipse中导入android项目
  5. Linux下的两种timer方法 (Android 下NDK开发)
  6. Android中VideoView播放当前工程中视频文件的方法
  7. Android Studio 中报错 程序包org.apache.http不存在 的解决方法
  8. Android中使用Makefile编译程序和库的方法

随机推荐

  1. Android中三星调用系统相机拍照后旋转的
  2. android 关于tts的一些参数
  3. 搭建android测试环境
  4. Android中通过Intent 调用图片、视频、音
  5. Android(安卓)EditText输入限制最大字符
  6. android 自定义控件属性
  7. Android——全屏显示的两种方式
  8. Android加速度传感器
  9. Android(安卓)IDL 小例子
  10. [置顶] Android(安卓)系列:安装Android(安