从 ANDROID STUDIO 导入到 ECLIPSE
http://www.nodeclipse.org/projects/gradle/android/Importing-from-Android-Studio-into-Eclipse
描述所需的步骤
截至 2014 年 9 月,在此处复制粘贴
欢迎在GitHub提出问题。
首先,使用Eclipse-ADT创建项目更容易,添加build.gradle并导入Android Studio
通过选择 build.gradle,然后选择其他方式。
单项目
请参阅下面的第 2 步
多项目
- 将
.project文件添加到根目录
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MyApplicationName</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
(你也可以使用Nodeclipse CLI)
例如从 froject 根 C:\Users\username\AndroidStudioProjects\MyApplicationName 运行 nodeclipse -g
复制该路径(例如,在 Android Studio 中的“复制路径”Ctrl+Shift+C),
在 Eclipse File -> Import -> General / Existing Project into workspace
此时,您实际上并不需要 ADT。 Eclipse 就像查看器,
但是您已经可以启动 Gradle build 、 installDebug 或在设备上运行(当您定义了 run 任务时)
您可以在 Eclipse 中进行的进一步操作
- 对于每个模块(如
mobile 或wear)都这样做
2.1 为Android项目添加2个标准.files如下
(您可以通过使用 Eclipse-ADT 创建新项目来获取它们,
只需要改"src" path="src/main/java"):
<?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"?>
<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>
(来源:nodeclipse.org)
2.2 创建操作系统符号链接
在 Lunix 上
ln -s src/main/res res
ln -s src/main/AndroidManifest.xml AndroidManifest.xml
在 Windows 上,我还不知道可以始终使用的优雅方式:
symbolic links on Windows
mklink /D res src/main/res
mklink AndroidManifest.xml src/main/AndroidManifest.xml
Windows 7 has mklink util,但它在我的电脑上不起作用。
我找到了一个很棒的Junction util
并且可以做到junction res src/main/res,但是对于文件的链接是创建 .lnk 文件(又名 Windows 快捷方式)。
我发现Git Bash 可以执行ln -s src/main/AndroidManifest.xml AndroidManifest.xml,但它会创建副本,而不是链接。
(来源:nodeclipse.org)
2.3 添加gen文件夹
2.4 添加project.properties
target=android-15
2.5 导入为现有项目
点击mobile,Ctrl+Alt+C
文件 -> 导入 -> 常规/现有项目到工作区
完成。
当然限制是:
- Eclipse 仍在使用 ADT 构建
- 通过 gradle 添加的依赖项对 ADT 不可见(但
libs 文件夹中的 jars 当然是共享的)
好东西是:
http://www.nodeclipse.org/projects/gradle