Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Android Studio and Eclipse for the same project? [duplicate]

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.

like image 494
SolidSnake4444 Avatar asked May 25 '13 02:05

SolidSnake4444


4 Answers

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

like image 87
Santacrab Avatar answered Oct 14 '22 01:10

Santacrab


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

like image 23
Xavier Ducrohet Avatar answered Oct 13 '22 23:10

Xavier Ducrohet


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.

like image 36
Raghu Avatar answered Oct 14 '22 01:10

Raghu


UPDATE: see 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 How to use Gradle to generate Eclipse and Intellij project files for Android projects

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 How to import Android Studio project in Eclipse?

.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 Can't run imported gradle android project in Eclipse

like image 28
Paul Verest Avatar answered Oct 14 '22 01:10

Paul Verest