0

I would like to use gradle for my Android/Eclipse project because I want to be able to install a development version of my app next to the released version (as seen here: What is a practical way to install stable and development app versions simultaneously?)

Using the command line for doing so is OK for me.

So I moved the src folder of my project to src/main/java and created a build.gradle file (as described here: http://www.nodeclipse.org/projects/gradle/android/Make-Android-Eclipse-project-ready-for-Android-Studio):

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}
apply plugin: 'android'
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}
android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

    androidTest.setRoot('tests')
    }
}

But when I run gradle build, I get this error:

FAILURE: Build failed with an exception.
...
> Could not create plugin of type 'AppPlugin'.

I already found that error on stackoverflow. Some people say it's because of using the wrong version of gradle. (Gradle is issuing an error "Could not create plugin of type 'AppPlugin'")

My questions:

  • As far as I understand, this version number in build.gradle (0.12.+) is the version of the gradle plugin and not of gradle itself. How can I find out which gradle plugin version I'm using?
  • And where does this plugin come from? Is it part of the gradle installation? Or part part of Eclipse? Or of ADT?
  • I installed Gradle IDE as Eclipse plugin. Does it interfere with a regular gradle installation?
Community
  • 1
  • 1
MaxGyver
  • 428
  • 7
  • 21

1 Answers1

0

After some more research, finally I succeeded compiling my app with gradle.

Just in case somebody else has the same problem, here is what I did:

  • Right click your Android project in Eclipse -> Export -> Android -> Generate Gradle build files.
  • This creates build.gradle, gradlew, gradlew.bat and settings.gradle (in my case some levels above my project). Don't move these files into your project folder.
  • Then run ./gradlew build. This will download the gradle plugin automatically (afaik) and create three apk's in [PROJECT FOLDER]/build/outputs/apk.
MaxGyver
  • 428
  • 7
  • 21
  • 1
    Id suggest you simple move to Android Studio and use Gradle as well. The latest Android Gradle plugin is `com.android.tools.build:gradle:1.1.2` and use `apply plugin: 'com.android.application'`. – Jared Burrows Mar 05 '15 at 17:20