如何在Eclipse中导入Android Studio项目?

时间:2023-01-13 22:30:04

i have made a project in Android Studio , now i want to import that project into Eclipse, there are options to convert eclipse to Android Studio , but how to convert Android studio to Eclipse?

我在Android Studio中做了一个项目,现在我想把这个项目导入到Eclipse中,有将Eclipse转换成Android Studio的选项,但是如何将Android Studio转换成Eclipse呢?

3 个解决方案

#1


15  

As the others say, a full import is not possible, but just try a manual 'import'. The key files for an Android project are the Java sourcecode (src directory), the resource XML files and the Manifest. Just create a new Android project in Eclipse and simply copy these files over. You may have to create a new package structure, so construct the necessary packages and copy each sourcefile over and refactor the package name if necessary. If you use any additional libraries, you may have to manually import them as well.

正如其他人所说,完全导入是不可能的,但请尝试手动“导入”。Android项目的关键文件是Java sourcecode (src目录)、资源XML文件和清单。只需在Eclipse中创建一个新的Android项目,并将这些文件复制过来。您可能需要创建一个新的包结构,因此构建必要的包,并将每个源文件复制过来,并在必要时重构包名。如果您使用任何其他的库,您可能还需要手动导入它们。

#2


5  

IMPORTING FROM ANDROID STUDIO INTO ECLIPSE

从ANDROID STUDIO导入ECLIPSE

http://www.nodeclipse.org/projects/gradle/android/Importing-from-Android-Studio-into-Eclipse describes steps needed

http://www.nodeclipse.org/projects/gradle/android/Importing-from-Android-Studio-into-Eclipse描述所需的步骤

http://www.nodeclipse.org/projects/gradle/MyApplicationName.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink-done.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink-done.PNG

Copy-paste here as of September 2014

复制粘贴到2014年9月。


welcome to raise issue on GitHub.

欢迎在GitHub上提出问题。

First, it is easier to create project with Eclipse-ADT, add build.gradle and import into Android Studio by selecting that build.gradle, then other way around.

首先,使用Eclipse-ADT、add build创建项目更容易。通过选择这个构建来进入Android Studio。格蕾尔,然后反过来。

Single-project

see step 2 below

请参见下面的步骤2

Multi-project
  1. Add .project file into root
  2. 将.project文件添加到根目录中

<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>MyApplicationName</name> <comment></comment> <projects> </projects> <buildSpec> </buildSpec> <natures> </natures> </projectDescription>

< ?xml version = " 1.0 " encoding = " utf - 8 " ?b0 MyApplicationName < comments > 0 1 2

(you can also use Nodeclipse CLI ) e.g. from froject root C:\Users\username\AndroidStudioProjects\MyApplicationName run nodeclipse -g

(您还可以使用Nodeclipse CLI)如从froject根C:\Users\username\ AndroidStudioProjects \ MyApplicationName Nodeclipse - g

Copy that path (e.g. in Android Studio "Copy Path" Ctrl+Shift+C),
in Eclipse File -> Import -> General / Existing Project into workspace

复制路径(例如,在Android Studio“复制路径”Ctrl+Shift+C),在Eclipse文件-> Import -> General /现有项目到工作区

http://www.nodeclipse.org/projects/gradle/MyApplicationName.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName.PNG

At this point, you don't really need to have ADT. Eclipse is like Viewer, but you already can launch Gradle build , installDebug or run on Device (when you have defined run task)

此时,您并不真正需要ADT。Eclipse类似于查看器,但是您已经可以在设备上启动等级构建、安装调试或运行(当您定义了运行任务时)

Further operation you can do within Eclipse

您可以在Eclipse中进行进一步的操作

  1. For every module (as mobile or wear) do
  2. 对于每个模块(移动或磨损)都是如此

2.1 Add 2 standard .files for Android project as below (you can get them by creating new project with Eclipse-ADT, only need to change "src" path="src/main/java"):

2.1为Android项目增加2个标准的.file如下(使用Eclipse-ADT创建新项目,只需要更改“src”路径=“src/main/java”即可获得):

  • .project :
  • . project:

<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>MyApplicationName-mobile</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> </buildSpec> <natures> <nature>com.android.ide.eclipse.adt.AndroidNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription>

< ?xml version = " 1.0 " encoding = " utf - 8 " ?>< projectDescription> MyApplicationName-mobile > /name> 0 com.android.ide.eclipse.adt. com.android.ide.eclipse.adt。预编译器 org.eclipse.jdt.core。 com.android.ide.ide.eclipse.adt >。 com.android.ide.eclipse.adt >自然AndroidNature < / > <自然> org.eclipse.jdt.core。自然javanature < / > < /性质> < / projectDescription >

  • .classpath :
  • . classpath:

<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/main/java"/> <classpathentry kind="src" path="gen"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry kind="output" path="bin/classes"/> </classpath>

< ?xml version = " 1.0 " encoding = " utf - 8 " ?style = ' font - size: 9.0 pt; font - family:宋体;mso - ascii - font - family: tahoma; mso - hansi - font - family:style = ' font - family:宋体;mso - ascii - font - family: tahoma; mso - hansi - font - family:library "/>

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile.PNG

2.2 create OS symbolic links

2.2创建OS符号链接

On Lunix

在Lunix

ln -s src/main/res res
ln -s src/main/AndroidManifest.xml AndroidManifest.xml

On Windows I don't yet know grace way that would work always:

在Windows上,我还不知道什么是优雅的工作方式:

symbolic links on Windows

Windows上的符号链接

mklink /D res src/main/res
mklink AndroidManifest.xml src/main/AndroidManifest.xml

Windows 7 has mklink util, but it just did not work on my PC.

Windows 7有mklink util,但它只是没有在我的PC上运行。

I found a great Junction util and could do junction res src/main/res, but for link to file is created .lnk file (aka Windows shortcut).

我发现了一个很棒的结点util,它可以做结点res /main/res,但是对文件的链接被创建为。lnk文件(又名Windows快捷方式)。

I discovered that Git Bash can execute ln -s src/main/AndroidManifest.xml AndroidManifest.xml but it creates copy, not link.

我发现Git Bash可以执行ln -s src/main/AndroidManifest。xml AndroidManifest。但它创建的是副本,而不是链接。

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink.PNG

2.3 Add gen folder

2.3添加创文件夹

2.4 add project.properties

2.4添加project.properties

target=android-15

目标= android-15

2.5 Import as existing project

2.5导入为现有项目。

click on mobile , Ctrl+Alt+C
File -> Import -> General / Existing Project into workspace

点击移动,Ctrl+Alt+C文件->导入->通用/现有项目进入工作区

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink-done.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink-done.PNG

DONE.

完成了。

Of course limitations are:

当然限制:

  • Eclipse is still using ADT to build
  • Eclipse仍然使用ADT构建。
  • dependencies added via gradle are not visible to ADT (but jars in libs folder are shared of course)
  • 通过gradle添加的依赖项对ADT是不可见的(但是libs文件夹中的jar当然是共享的)

Good things are:

好东西是:

  • you can use more stable Eclipse ADT for developing and debugging
  • 您可以使用更稳定的Eclipse ADT进行开发和调试
  • at the same time you can use and/or experiment with new build system in the same IDE as second one.
  • 同时,您可以在第二个IDE中使用和/或试验新的构建系统。

http://www.nodeclipse.org/projects/gradle

http://www.nodeclipse.org/projects/gradle

#3


1  

try install the gradle plugin in the eclipse. THis will work for some apps.

尝试在eclipse中安装gradle插件。这对于一些应用程序来说是可行的。

The following update sites are available:

以下更新网站可供选择:

http://dist.springsource.com/milestone/TOOLS/gradle (latest milestone build) http://dist.springsource.com/release/TOOLS/gradle (latest release) Pasting the above URLs into a web browser will not work. You need to follow the instructions given below to use an Eclipse update site.

http://dist.springsource.com/milestone/TOOLS/gradle(最新的里程碑构建)http://dist.springsource.com/release/TOOLS/gradle(最新的发布)将上述url粘贴到web浏览器将不起作用。要使用Eclipse更新站点,您需要遵循下面给出的说明。

In Eclipse Open Help >> Install New Software Paste a Gradle update site link into the "Work with" text box. Click the Add button at the top of the screen. Ensure that the option "Group Items by Category" is enabled. Select the top-level node 'Extensions / Gradle Integration'. Click "Next". This may take a while. Review the list of software that will be installed. Click "Next" again. Review and accept licence agreements and Click "Finish".

在Eclipse打开帮助>>安装新的软件,将一个升级更新站点链接粘贴到“Work with”文本框中。单击屏幕顶部的Add按钮。确保“按类别分组”选项被启用。选择*节点'Extensions / Gradle Integration'。单击“下一步”。这可能需要一段时间。查看将要安装的软件列表。再次单击“下一步”。审查和接受许可协议并点击“完成”。

如何在Eclipse中导入Android Studio项目?

#1


15  

As the others say, a full import is not possible, but just try a manual 'import'. The key files for an Android project are the Java sourcecode (src directory), the resource XML files and the Manifest. Just create a new Android project in Eclipse and simply copy these files over. You may have to create a new package structure, so construct the necessary packages and copy each sourcefile over and refactor the package name if necessary. If you use any additional libraries, you may have to manually import them as well.

正如其他人所说,完全导入是不可能的,但请尝试手动“导入”。Android项目的关键文件是Java sourcecode (src目录)、资源XML文件和清单。只需在Eclipse中创建一个新的Android项目,并将这些文件复制过来。您可能需要创建一个新的包结构,因此构建必要的包,并将每个源文件复制过来,并在必要时重构包名。如果您使用任何其他的库,您可能还需要手动导入它们。

#2


5  

IMPORTING FROM ANDROID STUDIO INTO ECLIPSE

从ANDROID STUDIO导入ECLIPSE

http://www.nodeclipse.org/projects/gradle/android/Importing-from-Android-Studio-into-Eclipse describes steps needed

http://www.nodeclipse.org/projects/gradle/android/Importing-from-Android-Studio-into-Eclipse描述所需的步骤

http://www.nodeclipse.org/projects/gradle/MyApplicationName.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink-done.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink-done.PNG

Copy-paste here as of September 2014

复制粘贴到2014年9月。


welcome to raise issue on GitHub.

欢迎在GitHub上提出问题。

First, it is easier to create project with Eclipse-ADT, add build.gradle and import into Android Studio by selecting that build.gradle, then other way around.

首先,使用Eclipse-ADT、add build创建项目更容易。通过选择这个构建来进入Android Studio。格蕾尔,然后反过来。

Single-project

see step 2 below

请参见下面的步骤2

Multi-project
  1. Add .project file into root
  2. 将.project文件添加到根目录中

<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>MyApplicationName</name> <comment></comment> <projects> </projects> <buildSpec> </buildSpec> <natures> </natures> </projectDescription>

< ?xml version = " 1.0 " encoding = " utf - 8 " ?b0 MyApplicationName < comments > 0 1 2

(you can also use Nodeclipse CLI ) e.g. from froject root C:\Users\username\AndroidStudioProjects\MyApplicationName run nodeclipse -g

(您还可以使用Nodeclipse CLI)如从froject根C:\Users\username\ AndroidStudioProjects \ MyApplicationName Nodeclipse - g

Copy that path (e.g. in Android Studio "Copy Path" Ctrl+Shift+C),
in Eclipse File -> Import -> General / Existing Project into workspace

复制路径(例如,在Android Studio“复制路径”Ctrl+Shift+C),在Eclipse文件-> Import -> General /现有项目到工作区

http://www.nodeclipse.org/projects/gradle/MyApplicationName.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName.PNG

At this point, you don't really need to have ADT. Eclipse is like Viewer, but you already can launch Gradle build , installDebug or run on Device (when you have defined run task)

此时,您并不真正需要ADT。Eclipse类似于查看器,但是您已经可以在设备上启动等级构建、安装调试或运行(当您定义了运行任务时)

Further operation you can do within Eclipse

您可以在Eclipse中进行进一步的操作

  1. For every module (as mobile or wear) do
  2. 对于每个模块(移动或磨损)都是如此

2.1 Add 2 standard .files for Android project as below (you can get them by creating new project with Eclipse-ADT, only need to change "src" path="src/main/java"):

2.1为Android项目增加2个标准的.file如下(使用Eclipse-ADT创建新项目,只需要更改“src”路径=“src/main/java”即可获得):

  • .project :
  • . project:

<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>MyApplicationName-mobile</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> </buildSpec> <natures> <nature>com.android.ide.eclipse.adt.AndroidNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription>

< ?xml version = " 1.0 " encoding = " utf - 8 " ?>< projectDescription> MyApplicationName-mobile > /name> 0 com.android.ide.eclipse.adt. com.android.ide.eclipse.adt。预编译器 org.eclipse.jdt.core。 com.android.ide.ide.eclipse.adt >。 com.android.ide.eclipse.adt >自然AndroidNature < / > <自然> org.eclipse.jdt.core。自然javanature < / > < /性质> < / projectDescription >

  • .classpath :
  • . classpath:

<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/main/java"/> <classpathentry kind="src" path="gen"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry kind="output" path="bin/classes"/> </classpath>

< ?xml version = " 1.0 " encoding = " utf - 8 " ?style = ' font - size: 9.0 pt; font - family:宋体;mso - ascii - font - family: tahoma; mso - hansi - font - family:style = ' font - family:宋体;mso - ascii - font - family: tahoma; mso - hansi - font - family:library "/>

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile.PNG

2.2 create OS symbolic links

2.2创建OS符号链接

On Lunix

在Lunix

ln -s src/main/res res
ln -s src/main/AndroidManifest.xml AndroidManifest.xml

On Windows I don't yet know grace way that would work always:

在Windows上,我还不知道什么是优雅的工作方式:

symbolic links on Windows

Windows上的符号链接

mklink /D res src/main/res
mklink AndroidManifest.xml src/main/AndroidManifest.xml

Windows 7 has mklink util, but it just did not work on my PC.

Windows 7有mklink util,但它只是没有在我的PC上运行。

I found a great Junction util and could do junction res src/main/res, but for link to file is created .lnk file (aka Windows shortcut).

我发现了一个很棒的结点util,它可以做结点res /main/res,但是对文件的链接被创建为。lnk文件(又名Windows快捷方式)。

I discovered that Git Bash can execute ln -s src/main/AndroidManifest.xml AndroidManifest.xml but it creates copy, not link.

我发现Git Bash可以执行ln -s src/main/AndroidManifest。xml AndroidManifest。但它创建的是副本,而不是链接。

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink.PNG

2.3 Add gen folder

2.3添加创文件夹

2.4 add project.properties

2.4添加project.properties

target=android-15

目标= android-15

2.5 Import as existing project

2.5导入为现有项目。

click on mobile , Ctrl+Alt+C
File -> Import -> General / Existing Project into workspace

点击移动,Ctrl+Alt+C文件->导入->通用/现有项目进入工作区

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink-done.PNG

http://www.nodeclipse.org/projects/gradle/MyApplicationName-mobile-symlink-done.PNG

DONE.

完成了。

Of course limitations are:

当然限制:

  • Eclipse is still using ADT to build
  • Eclipse仍然使用ADT构建。
  • dependencies added via gradle are not visible to ADT (but jars in libs folder are shared of course)
  • 通过gradle添加的依赖项对ADT是不可见的(但是libs文件夹中的jar当然是共享的)

Good things are:

好东西是:

  • you can use more stable Eclipse ADT for developing and debugging
  • 您可以使用更稳定的Eclipse ADT进行开发和调试
  • at the same time you can use and/or experiment with new build system in the same IDE as second one.
  • 同时,您可以在第二个IDE中使用和/或试验新的构建系统。

http://www.nodeclipse.org/projects/gradle

http://www.nodeclipse.org/projects/gradle

#3


1  

try install the gradle plugin in the eclipse. THis will work for some apps.

尝试在eclipse中安装gradle插件。这对于一些应用程序来说是可行的。

The following update sites are available:

以下更新网站可供选择:

http://dist.springsource.com/milestone/TOOLS/gradle (latest milestone build) http://dist.springsource.com/release/TOOLS/gradle (latest release) Pasting the above URLs into a web browser will not work. You need to follow the instructions given below to use an Eclipse update site.

http://dist.springsource.com/milestone/TOOLS/gradle(最新的里程碑构建)http://dist.springsource.com/release/TOOLS/gradle(最新的发布)将上述url粘贴到web浏览器将不起作用。要使用Eclipse更新站点,您需要遵循下面给出的说明。

In Eclipse Open Help >> Install New Software Paste a Gradle update site link into the "Work with" text box. Click the Add button at the top of the screen. Ensure that the option "Group Items by Category" is enabled. Select the top-level node 'Extensions / Gradle Integration'. Click "Next". This may take a while. Review the list of software that will be installed. Click "Next" again. Review and accept licence agreements and Click "Finish".

在Eclipse打开帮助>>安装新的软件,将一个升级更新站点链接粘贴到“Work with”文本框中。单击屏幕顶部的Add按钮。确保“按类别分组”选项被启用。选择*节点'Extensions / Gradle Integration'。单击“下一步”。这可能需要一段时间。查看将要安装的软件列表。再次单击“下一步”。审查和接受许可协议并点击“完成”。

如何在Eclipse中导入Android Studio项目?