48

I have Android project with standard build.gradle (also I added android annotations).

Also I installed Gradle plugin (from http://dist.springsource.org/release/GRECLIPSE/e4.3/) to my Eclipse (Kepler) and converted project to Gradle project.

Unfortunately I cannot run Gradle build on my Eclipse (in cmd line everything works).

My question is how to make Eclipse works with Gradle just like with Maven.

MAGx2
  • 3,149
  • 7
  • 33
  • 63
  • 1
    http://stackoverflow.com/questions/16745793/how-do-you-open-an-android-studio-project-in-eclipse – Raghunandan Nov 11 '13 at 17:35
  • 2
    Long story short: Eclipse does not support Android+Gradle? – MAGx2 Nov 11 '13 at 17:38
  • 1
    No. But it's still possible to have a project that can be developed & built on both Eclipse and Android Studio/Gradle. (Easiest if you first create the project on Eclipse, use the old-style layout.) – Jonik Jan 09 '14 at 19:00
  • i just imported an ansdroid studio project into eclipse. other than adding a .project file to the main directory and also to app/, it looks like there were no changes. – Ray Tayek Nov 13 '15 at 01:21
  • Has anyone tried this: https://gradle.org/press-release/eclipse-gradle/ – Pawan Dec 02 '15 at 07:12

4 Answers4

24

In order to be able to build an Android gradle project with Eclipse I followed these instructions:

  1. Install these Eclipse plugins:

    • Gradle IDE (3.4.0)
    • Android Development Tools (22.3.0)
  2. If you have an old-style android project layout, change your build.gradle to configure source directories as explained in the Android Gradle User Guide.

  3. If you have a gradle android project layout, create two symbolic links into the root of your project.

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

I hope it helps!

Israel Varea
  • 2,600
  • 2
  • 17
  • 24
  • Did you intall any plugins to Eclipse? – MAGx2 Dec 27 '13 at 15:43
  • 1
    He mentioned: "Gradle IDE (3.4.0), Android Development Tools (22.3.0)" – saiyancoder Dec 30 '13 at 01:36
  • 2
    Additionally I installed Groovy/Grails ToolSuite (GGTS) plugin to have syntax highlighting for the build.gradle file. – Israel Varea Jan 09 '14 at 15:33
  • 1
    I've been trying to get this and related projects to work for hours. Can you post a sample project somewhere? – joe Jan 12 '14 at 19:50
  • 5
    Googling for "Gradle IDE (3.4.0)" brings up the Eclipse Marketplace version, which failed to install for me. The instructions on https://github.com/spring-projects/eclipse-integration-gradle/ work. – Heath Borders Jan 31 '14 at 18:41
  • 1
    how to create those two symbolic links? – Jacek Kwiecień Apr 09 '14 at 18:38
  • In linux: ln -s src/main/res res;ln -s src/main/AndroidManifest.xml AndroidManifest.xml – Israel Varea Apr 10 '14 at 07:51
  • 2
    In Windows creating symbolic links is a little bit more complicated but they work the same like on Linux. I suggest using this tool https://code.google.com/p/symlinker/ – Igor Čordaš Apr 10 '14 at 15:48
  • Is there a way to specify eclipse-specific configuration in build.gradle that avoids creating the symbolic links? – inder Aug 31 '14 at 22:42
  • This is not full or fake answer. Please share what are .classpath and .project values? That would show usage of plugins in the project and not the fact that Eclipse has them. – Paul Verest Sep 28 '14 at 03:42
3

Read Is it possible to use the Gradle build system for Android with Eclipse?

try Nodeclipse/Enide Gradle for Eclipse (marketplace)

Some screenshots for Gradle for Eclipse:

Community
  • 1
  • 1
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
2

I use neon eclipse for android developer with gradle integration. Also, I use gradle plugin (com.github.ginvavilon:android-eclipse) for generating .project and .classpath for new structure of android project (src/main/java; src/main/res ...). Flavors and build types are supported. And use that project as gradle-project

Vavilon
  • 21
  • 1
0
  1. Install Gradle:
    a. http://gradle.org/gradle-download/ b. Choose 2.1 from previous releases section. c. Unzip at convenient folder.(Ex : D:\Graddle\gradle-2.1) d. Set system environment variables. i. GRADLE_HOME as D:\Graddle\gradle-2.1) ii. GRADLE_OPTS as -XX:MaxPermSize=512m iii. %GRADLE_HOME%\bin to Path iv. Set ANDROID_HOME ( Ex: D:\android-sdk) v. Append “%ANDROID_HOME %\platform-tools” to path.

e. Open command prompt and check gradle is set. May use gradle -version to check.

  1. Install Gradle eclipse PlugIn: a. Launch Eclipse b. Help > Eclipse Market Place c. Search “gradle” d. In that choose “Nodeeclipse/enide” e. Select all listed, accept & install. f. Restart eclipse once installed.

  2. Set Gradle & Java Homes : a. Launch eclipse. b. Window > Preferences > Gradle EnIDE c. Set these if not set : i. Gradle home to use is set ( Ex: D:\Graddle\gradle-2.1) ii. Alternate JAVA_HOME to use is set ( Ex : C:\Program Files (x86)\Java\jdk1.7.0_60) iii. JVM options for GRADLE_OPTS is set to “-XX:MaxPermSize=512m”

  3. Build the Project: a. Expand PhoneDishAnywhere in eclipse Java explorer. b. Right click on build.gradle c. Run As > Gradle GUI d. Comand Line : gradle clean build e. Wait for build to complete : First time build will take several minutes. f. If Build dex error or Java heap space error : i. Open build.gradle in editor. ii. Set appropriate javaMaxHeapSize based on your java (javaMaxHeapSize=1024M for 32bit Java,2048M for 64bit Java) iii. May comment signing (//apply from: "$rootProject.projectDir/jenkins_config/gradle/signing.gradle";) to avoid signing for debug build. iv. Build again after these fixes.

  4. Install Build On device: a. Connect the device to m/c. b. Right click on build.gradle c. Run As > gradle installDebug Gradle Android start d. Wait for install to complete

rajkabbur
  • 187
  • 3