`
univasity
  • 浏览: 801473 次
  • 性别: 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 ...

    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代码-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代码-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-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代码-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代码-一个用来显示数学公式的库

    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代码-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代码-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代码-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 '...

    Android代码-fadingIndicator

    A simple indicator with fading animation for ViewPager in Android. Most of the existing indicators don’t provide a smooth transition, this library fades indicators in and out when pager flipped. ...

    50-Android-Hacks.pdf

    I started learning about Android back in 2009. Android version 1.5 had just been released, and it showed a lot of potential. In July 2009, thanks to a friend living in Australia, I got my first ...

    Android代码-android-segmentedtab

    In order to use the library, there are 3 different options: 1. Gradle dependency (recommended) Add the following to your build.gradle: repositories { jcenter() } dependencies { compile '...

    Android代码-android-gesture-detectors

    Android Gesture Detectors Framework Introduction Since I was amazed Android has a ...Maven  com.almeros.android-gesture-detectors  library  1.0 Tutorials Using gesture detectors If you wan

    Android代码-card.io-Android-SDK

    card.io provides fast, easy credit card scanning in mobile apps. Stay up to date Please be sure to keep your app up to date with the latest version of the SDK. All releases follow semantic versioning....

    Android代码-A simple library to add carousel view in android app.

    A simple yet flexible library to add carousel view in your android application. Download Gradle: compile 'com.synnapps:carouselview:0.1.5' Maven: com.synnapps carouselview 0.1.5 pom Usage ...

    Android代码-DBC-Android

    In your module's build.gradle file, add the dependency: dependencies { ... compile 'com.github.busybusy:DBC-Android:{LatestVersionHere}' } Usage Use the design by contract assertions throughout your...

    Android代码-ason

    in the Android SDK. As we all know, those stock classes tend to be a pain. They feel bulky, and make you try/catch way too many Exceptions. Table of Contents Dependency Gradle (Java) Gradle ...

Global site tag (gtag.js) - Google Analytics