简体   繁体   English

如何将现有的java项目导入android studio?

[英]How to import existing java project into android studio?

In my android studio project want to use existing java project code 在我的android studio项目中想要使用现有的java项目代码

I tried this way: 我试过这种方式:

  1. Click File > New Module. 单击文件>新模块。 Select Java Library and click Next. 选择Java Library,然后单击Next。

  2. Filled the required fields and clicked Finish. 填写必填字段,然后单击“完成”。

A new empty Java project library was created in my Android project. 在我的Android项目中创建了一个新的空Java项目库。

I need to use existing(java project) code to my android studio project, how can I do that? 我需要使用现有的(java项目)代码到我的android studio项目,我该怎么做?

It is not possible to access with out gradle file , 无法使用gradle文件访问

you can use these steps if your Java project in eclipse 如果你的Java项目在eclipse中,你可以使用这些步骤

1.Right Click on project select export a new window appears 1.右键单击项目选择导出出现一个新窗口

2.Select generate gradle build file then the select project click finish 2.选择生成gradle构建文件,然后选择项目单击完成

It will create your project with gradle file,then you can easily import 它将使用gradle文件创建您的项目,然后您可以轻松导入

File -> New -> Import module..... 文件 - >新建 - >导入模块.....

Select Import Project Instead Module

To import a project to Android Studio: 要将项目导入Android Studio:

  1. Start Android Studio and close any open Android Studio projects. 启动Android Studio并关闭所有打开的Android Studio项目。
  2. From the Android Studio menu select File > New > Import Project. 从Android Studio菜单中选择File> New> Import Project。 .
  3. Select the Eclipse ADT project folder with the AndroidManifest.xml file and click Ok. 选择带有AndroidManifest.xml文件的Eclipse ADT项目文件夹,然后单击“确定”。
  4. Select the destination folder and click Next. 选择目标文件夹并单击“下一步”。

For demo you may visit Getting Started with Android Studio for step by step approach . 对于演示,您可以访问Android Studio入门一步一步的方法。

Details 细节

https://developer.android.com/sdk/installing/migrate.html https://developer.android.com/sdk/installing/migrate.html

You can import a java project if it is a Gradle build project. 如果它是Gradle构建项目,则可以导入Java项目。 Otherwise android studio not allow to import other java projects. 否则android studio不允许导入其他java项目。

File >> New >> Import Project and select the Gradle build java project 文件>>新建>>导入项目并选择Gradle构建java项目

Thanks 谢谢

The following link can be referred to: 可以参考以下链接:

https://developer.android.com/studio/intro/migrate.html https://developer.android.com/studio/intro/migrate.html

Import Eclipse Projects to Android Studio 将Eclipse项目导入Android Studio

Import as a Project: 作为项目导入:

Start Android Studio and close any open Android Studio projects. 启动Android Studio并关闭所有打开的Android Studio项目。

 From the Android Studio menu click File > New > Import Project. Alternatively, from the Welcome screen, click Import project (Eclipse ADT, Gradle, etc) Select the Eclipse ADT project folder with the AndroidManifest.xml file and click Ok. Select the destination folder and click Next Select the import options and click Finish. 

Importing a Gradle-based IntelliJ project 导入基于Gradle的IntelliJ项目

If you are already using Gradle with your IntelliJ project, you can open it in Android Studio using the following steps: 如果您已将Gradle与IntelliJ项目一起使用,则可以使用以下步骤在Android Studio中打开它:

 Click File > New > Import Project. Select your IntelliJ project directory, and click OK. Your project will open in Android Studio. 

On Android Studio 2.3.3 Android Studio 2.3.3上

File -> New -> Import Project 文件 - > 新建 - > 导入项目

Easiest way to do this is to choose the 'open an existing project' option, find your project, and then find the 'app' folder. 最简单的方法是选择“打开现有项目”选项,找到您的项目,然后找到“app”文件夹。 Click on this to highlight it and then click 'Ok'. 单击此按钮突出显示它,然后单击“确定”。 This will then import your complete project 然后,这将导入您的完整项目

A simple google search gives you everything: https://www.google.co.za/search?q=import%20project%20to%20android%20studio 一个简单的谷歌搜索为您提供一切: https//www.google.co.za/search?q = import%20project%20to%20android%20studio

To import a project to Android Studio: 要将项目导入Android Studio:

  1. Start Android Studio and close any open Android Studio projects. 启动Android Studio并关闭所有打开的Android Studio项目。
  2. From the Android Studio menu select File > New > Import Project. 从Android Studio菜单中选择File> New> Import Project。 ... ...
  3. Select the Eclipse ADT project folder with the AndroidManifest.xml file and click Ok. 选择带有AndroidManifest.xml文件的Eclipse ADT项目文件夹,然后单击“确定”。
  4. Select the destination folder and click Next. 选择目标文件夹并单击“下一步”。

Google has made this tutorial: https://developer.android.com/sdk/installing/migrate.html 谷歌已经制作了这个教程: https//developer.android.com/sdk/installing/migrate.html

I have had issues before with this so I normally just create a new project and just copy all the classes, drawables, etc from the old project into the new project. 我之前遇到过这样的问题所以我通常只是创建一个新项目,然后将所有类,drawable等从旧项目复制到新项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM