maven-android-sdk-deployer 安装记录

[color=blue]附件是成功配置的例子[/color]

参考:Maven搭建Android开发环境 [url]http://blog.csdn.net/shuangyidehudie/article/details/14229665[/url]

Maven项目在编译及导入Eclipse时出现的错误汇总处理 [url]http://blog.csdn.net/netwalk/article/details/19071525[/url]
使用Maven开发Android的常见问题 [url]http://my.oschina.net/huami/blog/175570[/url]
[color=red]Android development with maven[/color] [url]http://www.blogjava.net/askcuix/archive/2011/03/07/345897.html[/url]

maven-android-sdk-deployer官方:[url]https://github.com/mosabua/maven-android-sdk-deployer[/url]
1.下载android ADT [url]http://developer.android.com/sdk/index.html[/url]
2.下载maven-android-sdk-deployer
3.配置maven
4.[color=red]要vpn,否则很难下载上面的东西和更新ADT[/color],不要问我为什么,我也搞不明白搞个技术都要跳墙。
5.安装命令和教程见官方,执行mvn命令的时候,注意,如果出错,就到D:\maven-android-sdk-deployer-master\extras\pom.xml注释掉出错内容,否则无法mvn clean install。
<modules>
<module>compatibility-v4</module>
<module>compatibility-v7-gridlayout</module>
<module>compatibility-v7-appcompat</module>
<module>compatibility-v7-mediarouter</module>
<module>compatibility-v13</module>
<!-- deprecated by Google, will leave in for a while in case someone wants to manually activate and use it -->
<!-- <module>analytics-v2</module> -->
<!-- deprecated by Google with Aug 2014, but still available for download
might remove then, see http://googleadsdeveloper.blogspot.ca/2014/02/since-joining-google-play-services-back.html -->
<!-- <module>admob-ads-sdk</module> -->
<!-- deprecated by Google, will leave in for a while in case someone wants to manually activate and use it -->
<!-- <module>gcm</module> -->
<module>google-play-services</module>
<module>google-play-services-froyo</module>
<module>play-licensing</module>
<module>play-apk-expansion</module>
</modules>

[color=red]因为<module>admob-ads-sdk</module>总是出错,可能也用不到,所以就先注释掉。[/color]
6. setting.xml
<pluginGroups>
<pluginGroup>com.jayway.maven.plugins.android.generation2</pluginGroup>
</pluginGroups>



[size=x-large][color=blue]一个pom.xml文件[/color][/size]: [color=red]注意,AndroidManifest.xml,project.properties和pom里面的sdk的level要一致。[/color]
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>WebView2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<!-- <sourceDirectory>src</sourceDirectory> -->
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<run>
<debug>true</debug>
</run>
<sdk>
<!-- 值就是所使用的sdk的level,它对应android sdk目录中的platforms/android-*目录 -->
<platform>18</platform>
</sdk>
<emulator>
<!-- 元素就对应你的AVD Manager名字 -->
<avd>ADTTest</avd>
</emulator>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>${project.build.sourceEncoding}</encoding>
<optimize>true</optimize>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<!--
我们想将所有的依赖库都打包,直接交给用户,这样用户不需要在做其他设置了,这里需要使用Assembly插件了,其说明参考Pre-defined Descriptor Files,这个参考文件也说明了有四种默认定义的打包方式,我们选择jar-with-dependencies,继续添加pom文件
-->
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>

这里讲讲maven-android_plugin,我这里使用的android版本是2.2.1,对应的level就是8。<platform>的值就是所使用的sdk的level,它对应android sdk目录中的platforms/android-*目录。<path>的默认值就是ANDROID_HOME环境变量,这里也可以hardcode一个绝对路径。要在模拟器中运行应用,就需要定义一个AVD Manager,<emulator>下的<avd>元素就对应你的AVD Manager名字。

要编译android应用就需要将目标平台的jar包含在pom中,就像之前提及到的,仅仅作为编译使用,所以我们将这个dependency的scope设成provided。

[color=red]运行步骤:[/color]
现在我们就可以测试一下这个helloworld级别的应用了。
首先在命令行中build这个应用。
[color=darkblue]mvn clean install[/color]

然后启动模拟器,maven将会尝试启动配置在pom.xml中的AVD,因此pom中的avd的名字一定要和实际的avd相同。
[color=darkblue]mvn android:emulator-start[/color]

最后,我们将应用部署到模拟器上。[color=red]好像要上面的命令启动,才能够部署[/color]。
[color=darkblue]mvn android:deploy[/color]

在运行应用前,我们可以打开android的log viewer,这对我们调试应用是很有帮助的。
adb logcat


[b][color=red]问题:[/color][/b]
1.如何进行断点调试?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值