zoukankan      html  css  js  c++  java
  • Ubuntu 14.04 Android 使用Maven二 创建自己的Mavenproject

    依据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.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

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

    点击执行,成功。




  • 相关阅读:
    Kotlin使用常见问题汇总
    浅谈Kotlin(五): 静态变量&静态方法
    浅谈Kotlin(八):空安全、空类型
    浅谈Kotlin(七):lateinit、by lazy 使用
    浅谈Kotlin(六):data class的使用
    实例:([Flappy Bird Qlearning]
    强化学习之MountainCarContinuous(注册自己的gym环境)
    seq2seq之双向解码
    AwesomeVisualCaptioning
    VUE hash路由和history路由的区别
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/3804537.html
Copyright © 2011-2022 走看看