Trying to create a standard Android project using Gradle which I will import into Eclipse.
Am using the following tools (Eclipse IDE along with plug-ins):
Am able to create a standard Gradle project but when I tried to follow the tutorial (to setup an Android / Gradle project) located at:
http://www.vogella.com/tutorials/AndroidBuild/article.html
apply plugin: 'android'
apply plugin: 'eclipse'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4+'
}
}
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
android {
buildToolsVersion "17.0"
compileSdkVersion 17
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
I got the following in my Eclipse's console:
FAILURE: Build failed with an exception.
Where: Build file '/GradleProjects/hello/build.gradle' line: 1
What went wrong: A problem occurred evaluating root project 'hello'.
Could not create plugin of type 'AppPlugin'.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Question(s):
(1) Is there a standard way to create an Android Gradle project (which one can add more to the build script later on) using Eclipse (e.g. writing the build script and / or importing into Eclipse as a Gradle project)?
(2) I know I am using the latest versions (both Android and Gradle) but it doesn't work when I try to add
classpath 'com.android.tools.build:gradle:1.10+'
Would really appreciate it if someone can point me to a good reference...
You can't import Gradle-based Android projects into Eclipse using Eclipse's Gradle support. Android Gradle projects use a lot of custom infrastructure in the Android plugin that Eclipse's Gradle support doesn't understand. Most importantly, Android doesn't use Java sourceSets.
There's no simple answer for this. To be able to use Gradle-based Android projects in Eclipse, someone will have to write an Eclipse plugin for it, which won't be a trivial task.
If you want to use the same project in both Android Studio and Eclipse, you'll need to set up a normal Eclipse project for it and bypass Gradle altogether on the Eclipse side. You'll have to keep the project in Eclipse-style directory structure, which it looks like you've already done based on how you set up your sourceSets.
As for your second question, you've crossed Gradle versions with Android-Gradle-plugin versions. The latest version of Gradle is 1.12; the latest version of the plugin is 0.10.2.