如何将现有的Java源项目添加到Android Studio [英] How to add exisiting java source project to Android Studio

查看:72
本文介绍了如何将现有的Java源项目添加到Android Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的纯Java代码git存储库,我想将其添加到我的Android项目中.

I have an existing git repository of pure Java code that I would like to add to my Android project.

我不想更改任何现有文件.我想保留现有的程序包名称,以简化对旧代码的维护.

I don't want to change any of the existing files. I want to keep my existing package names to simplify the maintenance of my legacy code.

在Eclipse中,您只需将现有项目的根目录添加到Java Build Path中即可.

In Eclipse, you can simply add the root of the existing project to your Java Build Path.

如何在Android Studio中执行相同的操作?

How to do the same in Android Studio?

推荐答案

我的解决方案是将Java项目导出到JAR.

My solution to this was to Export my Java project to a JAR.

然后,我将JAR添加到Android Studio项目中.文件">项目结构"将显示以下窗口:

And then, I added the JAR to the Android Studio project. File > Project Structure leads to this window:

那样,我可以原样使用我的文件.

That way, I could use my files untouched as such.

我对这种解决方案不太满意,因为它破坏了我的版本控制系统.

I am not so happy with this solution because it breaks my revision control system.

这篇关于如何将现有的Java源项目添加到Android Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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