如何把Android项目转换为Maven项目 [英] How to convert my Android project to a maven project

查看:142
本文介绍了如何把Android项目转换为Maven项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Eclipse和放大器开发的Andr​​oid项目;推到github上。

I have an Android project developed with Eclipse & pushed to github.

现在我想将我的 Android项目行家的项目,那怎么办?

Now I want to convert my Android project to a maven project, how to do that?

推荐答案

尽量遵循的入门指南的Maven的Andr​​oid的插件。为了您已经存在的项目转换,你基本上要:

Try to follow the Getting Started Guide of the maven-android-plugin. In order to convert your already existing project you basically have to:

1)创建一个的pom.xml 。对于这一点,你可以使用Maven原型描述这里

1) Create a pom.xml. For this you can use the maven archetype as described here:

mvn archetype:generate   
   -DarchetypeArtifactId=android-quickstart   
   -DarchetypeGroupId=de.akquinet.android.archetypes   
   -DarchetypeVersion=1.0   
   -DgroupId=your.company   
   -DartifactId=my-android-application

这将创建的pom.xml 和行家规定的目录结构。

This will create the pom.xml and the directory structure mandated by maven.

2)移动你的code到相应的文件夹下的的src / main / java下

2) Move your code into the respective folders under src/main/java.

3)请确保您有Android SDK的安装在你的路径,正确的Andr​​oid平台版本,并安装在你的POM引用。另外,还要确保你已经设置的所有环境变量所需的Maven的Andr​​oid的插件页面上

3) Make sure you have the android sdk installed and in your path, the correct android platform version installed and referenced in your pom. Also make sure you have set all environment variables as required on the maven-android-plugin page

4)发行 MVN全新安装在命令行上,并检查建筑工作

4) Issue mvn clean install on the command line and check if the build works

5)插上你的Andr​​oid设备,并发出 MVN安卓部署。这应该您的手机上安装的应用程序(可以验证设备的precence与 MVN机器人:设备如果您要执行在模拟器中的应用程序,开始它先用 MVN机器人:模拟器启动,然后将其部署

5) Plug in your Android device and issue mvn android:deploy. This should install the App on your mobile phone (you can verify the device's precence with mvn android:devices. If you want to execute the app in the emulator, start it first with mvn android:emulator-start and then deploy it.

6)删除旧文件和文件夹都不再需要了。

6) Remove old files and folders that are no longer necessary.

7)在Eclipse中,请确保您已启用Maven支持并重新导入您的项目。当Eclipse构建项目时,它可能会抱怨缺少Maven插件的支持。打开Eclipse的市场和安装Android配置为M2E,那么就应该没问题。

7) In Eclipse, make sure you have maven support enabled and re-import your project. When Eclipse builds the project, it may complain about missing maven plugin support. Open Eclipse Marketplace and install the Android Configurator for m2e, then it should be ok.

这篇关于如何把Android项目转换为Maven项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆