`
univasity
  • 浏览: 811819 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Maven In Android

阅读更多

Maven
一个项目管理工具,类似于Ant。相比Ant,Maven更强大,编写起来更简洁,并引入了仓库的概念。

官网:http://maven.apache.org/

 

配置构建环境
1.安装Android SDK
http://developer.android.com/sdk/index.html
下载并SDK Management.

下载需要的android平台版本,和对应版本的google api.

在系统环境变量中添加ANDROID_HOME变量,指向SDK根目录。还可以在Path中添加%ANDROID_HOME%\tools。

2.安装Maven Android SDK deployer工具
http://github.com/mosabua/maven-android-sdk-deployer
下载项目源码,解压到任意目录下。

定位到项目目录,执行以下命令:
// 如果你的SDK下载了完整的组件
mvn clean install

// 如果你想指定某个平台
mvn clean install -P 2.2

3.配置settings.xml
为了能在命令行中使用简短的插件名-android,你需要修改settings.xml如下:
<pluginGroups>
     <pluginGroup>
          com.jayway.maven.plugins.android.generation2
     </pluginGroup>
</pluginGroups>

在Android开发中使用Maven
在原有的Android目录下添加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.demo.quartzclock</groupId>
    <artifactId>quartzclock</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>QuartzClockDemo</name>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>2.2.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
   
     <repositories>
          <repository>
               <id>sonatype</id>
               <name>Sonatype Repository</name>
               <url>https://repository.sonatype.org/</url>
               <releases>
                    <enabled>true</enabled>
               </releases>
               <snapshots>
                    <enabled>false</enabled>
               </snapshots>
               <layout>default</layout>
          </repository>
     </repositories>
   
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>maven-android-plugin</artifactId>
                <version>2.8.4</version>
                <configuration>
                    <sdk>
                        <!-- platform or api level (api level 4 = platform 1.6)-->
                        <platform>8</platform>
                    </sdk>
                    <emulator>
                        <!-- the name of the avd device to use for starting the emulator -->
                        <avd>android2.2_HVGA</avd>
                    </emulator>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <!-- version 2.3 defaults to java 1.5, so no further configuration needed-->
                <version>2.3</version>
            </plugin>
        </plugins>
    </build>
</project>

Eclipse插件:Maven Android Plugin
请参考:
m2eclipse-android-integration
GettingStarted:http://code.google.com/a/eclipselabs.org/p/m2eclipse-android-integration/wiki/GettingStarted

maven-android-plugin
GettingStarted:http://code.google.com/p/maven-android-plugin/wiki/GettingStarted

------------------------------------------------------------------------------------------------------
由于本身Android的Manifest.xml已经配置了构建的属性,感觉Maven在这起的作用不大...

 

分享到:
评论
1 楼 guofengcn 2011-10-21  
http://rgladwell.github.com/m2e-android/
第三步,3. Install Android Connector这步骤怎么也不行啊,也没太明白。

R文件没有创建……你的好使?

相关推荐

    Android代码-Android Common Library Samples

    Some modules of project contain dependencies not included in Maven Central - to build such modules you need first install these dependencies in your local repository. To do this, please, download ...

    纯java版本的ZeroMQ,可用在Android上

    标题中的“纯java版本的ZeroMQ,可用在Android上”指的是ZeroMQ库的Java实现,它允许在Android平台上使用这个高性能的消息队列库。ZeroMQ,又称为ØMQ或0MQ,是一个开源的多协议、多平台的轻量级消息中间件,它提供...

    Android代码-Filepicker Android版

    filepicker-android Android version of Filepicker. Allow your users to pull in their content from Dropbox, Facebook, and more! ...The library provides an activity that your app...If you use Maven, you can in

    Android代码-android-async-http

    Latest Javadoc for 1.4.9 release are available here (also included in Maven repository): https://loopj.com/android-async-http/doc/ Features Make asynchronous HTTP requests, handle responses in ...

    解决android studio 3.0 加载项目过慢问题--maven仓库选择

    解决 Android Studio 3.0 加载项目过慢问题 - Maven 仓库选择 Android Studio 3.0 加载项目过慢问题是许多开发者遇到的一个常见的问题。这个问题的出现主要是由于 Maven 仓库的配置不当所致。在本文中,我们将介绍...

    Android代码-c2dm-android-pilot

    For android maven plugin specific help please see the official website: http://code.google.com/p/maven-android-plugin/ There is a matching application server side to this code written in Python. It ...

    android-async-http 源码

    Latest Javadoc for 1.4.9 release are available here (also included in Maven repository): https://loopj.com/android-async-http/doc/ Features Make asynchronous HTTP requests, handle responses in ...

    在安卓上运用的MVP模式开发框架 A framework for MVP pattern in android.zip

    A framework for MVP pattern in android.简易MVP在安卓上运用的MVP模式开发框架。A framework for MVP pattern in android.与传统MVP开发模式相反,EasyMVP是将activity,fragment, adapter作为presenter的mvp开发...

    Android代码-maven-plugins

    in your project's POM file or in your settings.xml file. Where you put the plugin settings depends on whether you want a specific setting to be configured globally or on a per-project basis. All GitHu

    Android代码-一个用来显示数学公式的库

    There are two ways you can add MathView to your project in Android Studio: From a remote Maven repository (jcenter). From a local .aar file. 1. Setup from a remote Maven repository (jcenter) Add ...

    Android代码-color picker for android

    This library is not released in Maven Central, but instead you can use JitPack add remote maven url in allprojects.repositories allprojects { repositories { maven { url "https://jitpack.io" } } } ...

    Android代码-Material版的文件选择器

    Material file picker library for Android Using Add repository url and dependency in application module gradle file: repositories { maven { url "http://dl.bintray.com/lukaville/maven" } } ...

    Android Studio 2021离线环境配置教程完整介绍

    **第二步**:在没有互联网连接的电脑上安装Android Studio,并将之前下载的所有资源文件复制到该电脑上,随后配置maven本地依赖,以便在无网络的情况下也能顺利进行Android应用的开发与测试。 #### 二、准备工作与...

    Android代码-QButton

    This library is available in jitPack which is the default Maven repository used in Android Studio. Gradle Step 1. Add it in your root build.gradle at the end of repositories allprojects { ...

    Android代码-ProductLayer-SDK-for-Android

    See ProductLayer in action in our prod.ly app. We have SHUT DOWN https://www.cocoanetics.com/2018/04/productlayer-post-mortem/ Usage Gradle compile 'com.productlayer.ply-android-sdk:0.5.1' compile '...

    Android代码-Android 层叠卡片控件,仿"探探app"

    maven { url 'https://jitpack.io' } } } // 2. Add the dependency in your app/build.gradle dependencies { compile 'com.github.fashare2015:StackLayout:1.0.0' } xml布局 父布局使用clipChildren="false...

    Android代码-DisqusSDK-Android

    This library implements the Disqus API for use in Android applications. This librar is ongoing Gradle settings repositories { maven { url 'https://dl.bintray.com/jjhesk/maven' } } dependencies { ...

    Android代码-JWTDecode.Android

    The library is be available both in Maven Central and JCenter. To start using it add this line to your build.gradle dependencies file: implementation 'com.auth0.android:jwtdecode:1.2.0' Usage Decode a...

    Android代码-Android-PdfMyXml

    Add Jitpack in your root build.gradle at the end of repositories: allprojects { repositories { ... maven { url "https://jitpack.io" } } } Add to your dependencies: dependencies { compile '...

Global site tag (gtag.js) - Google Analytics