How do you open an Android Studio project in Eclipse?

AndroidEclipseImportProjectAndroid Studio

Android Problem Overview


The new Android Studio allows for better Android development with better tools. I see a bunch of questions on how to transfer an eclipse project to android studio but what about the other way?

If you make an Android app in Android Studio, can you bring it back to Eclipse? If so, how?

This would be needed for specific eclipse plugins, such as the Blackberry Android plugin.

Thank you.

Android Solutions


Solution 1 - Android

You cannot import the project directly but it's not to hard to achieve it:

  • Create a new Android empty project in eclipse
  • Overwrite the fresh res/ folder and the AndroidManifest.xml file, with the ones from the Android Studio project
  • Copy the content of the java/ folder from the Android Studio project (it should contain your package name folder structure, like com/example/app/, and the java files of course) in the Eclipse src folder
  • Link your needed libraries if it's the case

Basically the Android application fundamental elements are the java files, the manifest file and the resources. From there you can build back a project in your favorite IDE

Solution 2 - Android

It's not possible. We intend to add support for Gradle-based project in ADT but it's not currently possible.

Solution 3 - Android

Step-by-Step process to import Android Studio Project into Eclipse...

  1. Start new Android Project in eclipse using wizard and fill following details from app/build.gradle

    ApplicationName and ProjectName : - You can find project name from .iml file in / folder PackageName : MinSDK, TargetSDK and CompileSDK

  2. Click Next in the wizard and make sure that you have "unchecked" 'Create Activity' and "Create Custom Icon". Click Finish.

  3. Open AndroidManifest.xml file in new created project. Copy "application", "uses-permission" etc tags as is from app/src/main/AndroidManifest.xml

  4. Source Files : Replace all contents in AndroidStudio/app/src/main/java to Eclipse//src folder.

  5. Resource Files : Replace all contents in AndroidStudio/app/src/main/res to Eclipse//res folder.

  6. Library files : Copy all libs from AndroidStudio/app/libs to Eclipse//libs folder.

  7. Dependency Library : Import and Add AppCompact as a dependent library using Properties->Android->Library->Add

  8. Resolve any errors to build. Clean and Build again as a last step.

  9. You may not be able to deploy it directly onto a phone but you can find .apk file generated in bin folder.

Solution 4 - Android

UPDATE: see https://stackoverflow.com/questions/27655099/one-android-project-for-eclipse-and-android-studio

Currently if you create Android project in Android Studio you will have hard times opening it in Eclipse. (However opening classic Android with added build.gradle in Android Studio should be easier)

So you can open (as general project) and then convert some modules into Eclipse project, but still it will not be fully functional (but for a quick view inside may suffice)

from https://stackoverflow.com/questions/17470831/how-to-use-gradle-to-generate-eclipse-and-intellij-project-files-for-android-pro

As answered in Issue 57668 by Android team (raised by @arcone)

> Project Member #2 [email protected] > > The eclipse plugin is not compatible with the android plugin. > > You will not be able to import an Android gradle project into Eclipse using the default Gradle support in Eclipse. > > To make it work in Eclipse we will have to change the Gradle plugin for Eclipse, the same way we are modifying the Gradle support in IntelliJ

That is Android team is working on gradle plugin for IntelliJ and gradle plugin for Eclipse needs to be updated too.

What is possible with Eclipse now is

THIS IS OUTDATED, see https://stackoverflow.com/questions/17481915/how-to-import-android-studio-project-in-eclipse/26092617#26092617

.1. import the project as general project

.project

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

import-android-gradle-as-general-project

.2. Put 2 Eclipse . "dot" files into modules into /OpenSpritz-Android/app/src/main and /OpenSpritz-Android/lib/src/main

add-eclipse-files

.project

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>OpenSpritz-Android-app</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>

.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="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>

.3. Import as Existing Android Code into Workspace

results

you can then browse code in familiar way, but even after that you won't be able to run with Eclipse ADT.

.4.

Now you can run build and tasks with gradle CLI or Nodeclipse/Enide Gradle for Eclipse (marketplace)

start

discuss at https://github.com/Nodeclipse/nodeclipse-1/issues/148

Also answered in https://stackoverflow.com/questions/22988475/cant-run-imported-gradle-android-project-in-eclipse

Solution 5 - Android

Import project then Properties > java build path > source tab....remove path to src....add path to java folder in the source code using add folde rbutton... then build your project as usual

Configure path to java folder where your source code resides

Solution 6 - Android

I think its not possible to import an android studio project to eclipse, without very much hand work.

Solution 7 - Android

I really miss the automatic build feature in Eclipse but also hate the speed and bugs in Eclipse for Mac. It would be nice to have the best of both worlds. The project layout in Eclipse and Android Studio has a lot in difference and I guess it would be very difficult if not impossible to change the default layout. Therefore, I tried to create an empty Android project in Eclipse. Then I deleted the physical folders and files and created linked resources to reference those in the Android Studio project and voila! It works.

Here is my resource mapping:

AS-Project/app/src/main/AndroidManifest.xml -> Eclipse-Project/AndroidManifest.xml  
AS-Project/app/src/main/res                 -> Eclipse-Project/res  
AS-Project/app/src/main/assets              -> Eclipse-Project/assets  
AS-Project/app/src/main/java                -> Eclipse-Project/src    
AS-Project/app/libs                         -> Eclipse-Project/libs-as  

Linked folder doesn't quite work for the "libs" folder. So I mapped it to a folder called "libs-as" and manually added the JARs to project build path. In the worst case I guess you could maintain two separate libs folders.

Eclipse Project layout

P.S. It would be a good idea to put two projects side by side and use location variables to reference relative paths (e.g. ${PARENT-1-PROJECT_LOC})

Solution 8 - Android

I just published a project that requires to work for Android Studio or Eclipse users. It's basically an Android Studio project, but I provided a gradle build file that developers can use to convert it to Eclipse.

Basically developers would have to run the following command to convert the project to Eclipse:

gradle -b eclipse.gradle eclipse

Here are the contents of eclipse.gradle:

apply plugin: 'java'
apply plugin: 'eclipse'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}

// Add the natures and build commands to the project
eclipse.project {
  	natures 'com.android.ide.eclipse.adt.AndroidNature'
	natures 'org.eclipse.jdt.core.javanature'
	buildCommands.clear();
	buildCommand 'com.android.ide.eclipse.adt.ResourceManagerBuilder'
	buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder'
	buildCommand 'org.eclipse.jdt.core.javabuilder'
	buildCommand 'com.android.ide.eclipse.adt.ApkBuilder'
}

// The source code is in the java folder
sourceSets.main.java.srcDirs 'java'

dependencies {
    // declare your dependencies here
}

Hope this helps

Adding step-by-step procedure.

  1. Install gradle. Note that if you have Android Studio you already have gradle.
  2. Create an eclipse.gradle file in the root folder of your Android Studio project and copy the contents of the eclipse.gradle mentioned above.
  3. Open a command prompt or terminal and run gradle -b eclipse.gradle
  4. Try to open in Eclipse

Solution 9 - Android

The published answer worked for me, but only after some mis-steps due to my inexperience with these IDEs. For any other beginner be careful with these ...

  1. use the same minimum, target and build SDKs
  2. use the exact same project name, and watch the sequence of project directories based on the package name, for the correct location of the .java file[s]
  3. for the /res folder copy over missing directories
  4. edit [i used NotePad] all matching xml files, carefully choosing the correct mix of entries, some from each

After this there may still be some errors to contend with, but with some persistence you should be able to correct them.

Solution 10 - Android

It's quite simple if you know the trick.

  • Replace the eclipse project Res folder with Android studio project's res folder.

  • Go inside java folder and copy all folders and paste inside src folder of eclipse project.

  • Open Android manifest of android studio project, copy all of the content and paste it in eclipse projects manifest.

  • clean and run the project.

Solution 11 - Android

Simple way to move project from android studio to eclipse.

  1. Import project in eclipse .There is no file in src folder in these project.

  2. Go to the java folder that is available in folder stucture which you imported in eclipse. Copy the folder which is inside java it would be most of the time started from 'com' and paste in source 'src' folder .

Now you can compile your projrct it would work. if your project require third party libs then add the required file also.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSolidSnake4444View Question on Stackoverflow
Solution 1 - AndroidSantacrabView Answer on Stackoverflow
Solution 2 - AndroidXavier DucrohetView Answer on Stackoverflow
Solution 3 - AndroidRaghuView Answer on Stackoverflow
Solution 4 - AndroidPaul VerestView Answer on Stackoverflow
Solution 5 - AndroidDennis MPView Answer on Stackoverflow
Solution 6 - AndroidErichView Answer on Stackoverflow
Solution 7 - AndroidKriz PoonView Answer on Stackoverflow
Solution 8 - AndroidricaloView Answer on Stackoverflow
Solution 9 - AndroidMickView Answer on Stackoverflow
Solution 10 - AndroidNikhil bohraView Answer on Stackoverflow
Solution 11 - AndroidGopal SharmaView Answer on Stackoverflow