曾经写过一篇Android环境配置的随笔,个人感觉特繁琐,既然有Maven,何不尝试用用Maven呢,经网上搜索这篇文章但不限于这些,而做了一个基于Maven的Android版的Hello Android World.
1, 前提安装sdk以及adt这些就不讲了。网上有的下,我这里的使用的插件是ADT-22.0.5, 要保持最新,可以关注一下官网。贴一张我的SDK Manager图在这里感觉一下。
2,生成MavenQuickStart项目,名为HelloMavenAndroid.
mvn archetype:generate -DarchetypeArtifactId=android-quickstart -DarchetypeGroupId=de.akquinet.android.archetypes -DarchetypeVersion=1.0.11 -DgroupId=com.vanceinfo.android -DartifactId=HelloMavenAndroid
3,导入Kepler, 修改一下.project文件如下,默认只有org.eclipse.jdt.core.javabuilder和org.eclipse.m2e.core.maven2Builder, nature节点中也只有org.eclipse.jdt.core.javanature和org.eclipse.m2e.core.maven2Nature,我在这里折腾了一天才发现加上com.android.ide.eclipse.adt.ResourceManagerBuilder,com.android.ide.eclipse.adt.PreCompilerBuilder,com.android.ide.eclipse.adt.ApkBuilder以及com.android.ide.eclipse.adt.AndroidNature才能算是真正的android项目。
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HelloMavenAndroid</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>