groovy / groovy-android-gradle-plugin

A Gradle plugin to support the Groovy language for building Android apps
Apache License 2.0
850 stars 116 forks source link

Unable to apply plugin #128

Closed IgorGanapolsky closed 8 years ago

IgorGanapolsky commented 8 years ago

Hello, I am unable to apply your plugin as: apply plugin: "groovyx.android"

I have set classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:1.0.0', but I get a build error:

Error:(25, 1) A problem occurred evaluating root project 'CrestronApp_Android'. Failed to apply plugin [id 'groovyx.android'] You must apply the Android plugin or the Android library plugin before using the groovy-android plugin

Please advise, Igor

AndrewReitz commented 8 years ago

Did you try applying the android plugin like the error suggests?

Help can not be provided without more details. What version of the android plugin are you using? What version of gradle?

In fact it would be extremely useful to see the entire build.gradle, and other relevant gradle files like settings.gradle.

IgorGanapolsky commented 8 years ago

@pieces029 What do you mean by

applying the android plugin

Ofcourse, my app is an Android app, and wouldn't be built in Android Studio had I not applied the android plugin.

Here is my build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.7.3'
        classpath "com.gradle:build-scan-plugin:1.0"
        classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:1.0.0'
    }
}

/**
 * This adds support for the Groovy language to Android.
 */
apply plugin: "groovyx.android"

/**
 * This allows our gradle build to be profiled and scanned by Gradle cloud.
 * More info about Gradle Build Scans here: https://scans.gradle.com/get-started?type=project
 */
apply plugin: "com.gradle.build-scan"
buildScan {
    licenseAgreementUrl = 'https://gradle.com/terms-of-service'
    licenseAgree = 'yes'
}

allprojects {
    repositories {
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

ext {
    buildToolsVersion = "24.0.2"
    supportLibVersion = "24.2.1"
    playServicesVersion = "9.4.0"
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
AndrewReitz commented 8 years ago

You have not applied the android plugin. See https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide or more information.

Since this is not a help form and this is not an issue with the plugin, I suggest anymore questions be posted to stack overflow.

IgorGanapolsky commented 8 years ago

@pieces029 Sir, the gradle plugin you speak of is applied in the module's build.gradle file:

apply plugin: 'com.android.model.application'

model {
    // Android app build
    android {
        compileSdkVersion = 24
        buildToolsVersion = rootProject.ext.buildToolsVersion

        defaultConfig {
            applicationId = 'com.myapp.andros'
            minSdkVersion.apiLevel = 16
            targetSdkVersion.apiLevel = 24
            versionCode = 1
            versionName = '1.0'
        }
    }
}

That is how Android projects are structured in Android Studio. As you can see, it is applied. So what next?

johnrengelman commented 8 years ago

@IgorGanapolsky any project that you apply groovyx.android must also have the com.android.application plugin installed

Per the README

apply plugin: 'com.android.application'
apply plugin: 'groovyx.android'

what you've posted above is that you've applied the android groovy plugin to your root project, but you've applied the android plugin to a sub-project. This is not a valid thing to do. Try moving apply plugin: "groovyx.android" to your module's build.gradle file.

IgorGanapolsky commented 8 years ago

@johnrengelman Tried that, still the same error.

This is not a valid thing to do

Says who? If you can get the groovy plugin to work in Android Studio for real, then let me know.

johnrengelman commented 8 years ago

The code snippets you have posted do not match the document at the root of this project. First, your sample is applying com.android.model.application and not com.android.application per the documentation.

Says who?

Says the guy who wrote this project according to how he documented to properly use this plugin in the README.

You can't do custom stuff and expect to get free support from people who have their own full time jobs. Why don't you try setting up a brand new project using the lazybones project and verify for yourself that is works in Android Studio. If it does, then it's an issue with how you are configuring your project and not with the plugin.

IgorGanapolsky commented 8 years ago

For anyone who is interested, it seems that groovy-android-gradle-plugin is not compatible with gradle-experimental (http://tools.android.com/tech-docs/new-build-system/gradle-experimental). Period.

AndrewReitz commented 8 years ago

Hi @IgorGanapolsky You are correct. I have not invested time into supporting something that is experimental. If you had mentioned you were using this earlier I could have told you it was not supported.

If you want to work on this I will gladly accept pull requests. Making a new more descriptive GitHub issue of what you would like added to this plugin as a feature request would also be helpful to allow others know that you are working on this.

chrisliiingo commented 3 years ago

Damn it @IgorGanapolsky, why did you leave us hanging? I need to know the rest of your story. Did you create that PR? Did you go on to become a major repo contributor, a groovy-android-gradle-plugin guru?

This is like a great book, but missing half the pages. 🤣