Using Xtend-Android Gradle plugin and LibGDX-generated Gradle build file

38 views
Skip to first unread message

Wutipong Wongsakuldej

unread,
Oct 11, 2016, 2:26:22 PM10/11/16
to Xtend Programming Language
Hi,

I'm trying to get Xtend Android Gradle plugin with LibGDX-generated Gradle build file. Basically I've added the following lines into the top-level build.gradle file.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'org.robovm:robovm-gradle-plugin:1.12.0'
        classpath "org.xtext:xtext-gradle-plugin:1.0.12" //<-Added
        classpath "org.xtext:xtext-android-gradle-plugin:1.0.12" // <- Added
    }
}


project(":android") {
    apply plugin: "android"
    apply plugin: "org.xtext.android.xtend" // <- Added
    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
    }
}

project(":core") {
    apply plugin: "java"
    apply plugin: "org.xtext.xtend" // <-Added

    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        compile "com.kotcrab.vis:vis-ui:1.0.1"
        compile 'org.eclipse.xtend:org.eclipse.xtend.lib:2.9.0' // <-Added
    }
}

The :android task throw me an error saying the the Android tasks have already been created.

Caused by: org.gradle.api.GradleException: Android tasks have already been created.
This happens when calling android.applicationVariants,
android.libraryVariants or android.testVariants.
Once these methods are called, it is not possible to
continue configuring the model.

I don't know if I incorrectly applies the plugin here though. 

Anyway I already have the desktop task working right now. Haven't test the ios task though, as I don't have a mac with me currently.

Can you please help with the error ? Let me know what information I have to provide.

Thank you.
Wutipong.
build.gradle

chrs wk

unread,
Oct 19, 2016, 6:16:39 AM10/19/16
to Xtend Programming Language
I have the same problem when upgrading the xtext-android-gradle-plugin in my Android projects to anything newer than 1.0.6.

Running Android Studio 2.2.1, Gradle 2.14.1, Android Build Tools 24.0.3, com.android.tools.build:gradle:2.1.3 (upgrading to the latest 2.2.1 breaks everything) with org.eclipse.xtend.lib:2.10.0 is barely a workable solution, with constant errors in the Event log, etc.

At the moment, it's not very fun to develop in Android Studio with Xtend, because when updating any of the endless Gradle/Android/Build related dependencies it seems like on a regular basis I step on a landmine that breaks everything. This is probably not Xtends fault, but more of a general problem with the Android Studio/Gradle combo.

How I miss the days of m2e-android and developing Android apps in Eclipse and Maven...

-Chris
Reply all
Reply to author
Forward
0 new messages