Add external dependency to Eclipse (or AS) project via Gradle

1,155 views
Skip to first unread message

Kenneth Kousen

unread,
Jun 4, 2013, 4:50:34 PM6/4/13
to adt...@googlegroups.com
Hi all,

When I use Gradle on a regular Java project that needs an external dependency, I add it to the dependencies block, as usual. Here I'm trying to use the RestTemplate from Spring Android:

repositories {
    mavenCentral()
    maven {
    }
}

dependencies {
    compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
    compile files('libs/android-support-v4.jar')
}

When I run a 'gradle build', that works and downloads the proper dependencies. Unfortunately, they're not added to the Eclipse (or Android Studio) projects. When it comes to a normal Java project in Eclipse, to fix that I add the eclipse plugin:

apply plugin: 'eclipse'

and run:
> gradle cleanEclipse eclipse

which adds the dependencies as "referenced libraries". Doing that on an Android project messes it up, though, and also doesn't add the external libraries.

How do I fix the Eclipse project? Do I have to manually find the downloaded jar and add it as an external jar file?

Thanks,

Ken Kousen
    

Xavier Ducrohet

unread,
Jun 4, 2013, 9:36:33 PM6/4/13
to adt...@googlegroups.com
Eclipse with Gradle is not supported yet. The existing Gradle plugin for Eclipse cannot (yet) support Android project.

As for Studio, if you import the Gradle project in Studio it should work without having to add the 'eclipse' or 'idea' plugin to your project.


    

--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!
Reply all
Reply to author
Forward
0 new messages