Skip to content

Instantly share code, notes, and snippets.

@devilmac
Last active August 29, 2015 14:03
Show Gist options
  • Save devilmac/ac925931febed9c4d922 to your computer and use it in GitHub Desktop.
Save devilmac/ac925931febed9c4d922 to your computer and use it in GitHub Desktop.
How to translate Gradle library to allow you to add it on your Eclipse project.
Hi all,
yesterday I had to deal a difficult question, that is how to load a Gradle library project on Eclipse without third party tools or similar.
As you already know, Eclipse is unable to load a Gradle project, but there is something that I'm sure someone don't know: Gradle itself can "translate" a project to make it able for Eclipse! Let's see how.
First of all, you have to add an environment variable that point to your Android SDK root folder. Done this, reboot your computer to apply the change. If this wouldn't work, add to the root folder's project a "local.properties" file containing this line: sdk.dir=pathToAndroidSDK.
Second step: you have to open the build.gradle file of the library (the file where you specify all specific attributes of the library) and add this line:
apply plugin: 'eclipse'
Open a terminal and navigate to the root of the project; after, type and execute this command:
gradlew eclipse
When the process is finished without errors, inside the library folder there will be these three files:
.classpath file;
.project file;
.settings folder.
Now you can load the project in Eclipse! But before yell "HOORAY!", you have to do all the necessary to make the project error free.
At the end, you can reference the "translated" project to your application/library project.
I hope this will help.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment