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

Build failed for groovy code #85

Closed marek-kuticka closed 8 years ago

marek-kuticka commented 8 years ago

Hi

Android studio 1.5.1. fails building simple project, with groovy classes included.

app.gradle file follows:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.7'
    }
}

apply plugin: 'com.android.application'

apply plugin: 'groovyx.grooid.groovy-android'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "farago.com.reader"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    //packagingOptions {
        // workaround for http://stackoverflow.com/questions/20673625/android-gradle-plugin-0-7-0-duplicate-files-during-packaging-of-apk
        //exclude 'META-INF/LICENSE.txt'
        //exclude 'META-INF/groovy-release-info.properties'
    //}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'org.bouncycastle:bcprov-jdk16:1.45'
    //compile 'org.codehaus.groovy:groovy:2.4.5:grooid'

}

In build I get error Error:Execution failed for task ':app:compileDebugGroovyWithGroovyc'.

No such property: bootClasspath for class: com.android.build.gradle.AppPlugin

I tried to include latest versions of all components, but build still fails.

can you recommend a setup, that works? maybe some specific versions of studio, java / plugins?

thx a lot

Marek

AndrewReitz commented 8 years ago

can you recommend a setup, that works?

I'd recommend checking out the sample https://github.com/groovy/groovy-android-gradle-plugin/blob/master/groovy-android-sample-app/sample-app.gradle

As for the error message you are recieving, it looks like the plugin version is getting screwed up. Could you try the latest snapshot version and see if the error goes away?

marek-kuticka commented 8 years ago

Hi. thx for answer. fun part is... I have also downloaded whole this "project" and imported it as gradle project. here the sample project works well. if I just copy files of sample project to different location, where nor directories on same level as sample app ( siblings ), are not there, neither its parent directory, then the build fails. I have tried to modify my .gradle file according to this sample but I did not succeed.

as for 0.3.8-SNAPSHOT I am somehow not able to download it, it is not found by Android Studio. ( I have tried also most various versions of all parts, still without success )

thx a lot

Marek

marek-kuticka commented 8 years ago

ok, managed to build the plugin to local maven repo, and rebuild my project with 0.3.8-SNAPSHOT but still no success, the error persists. thx a lot for help! Marek

ThanosFisherman commented 8 years ago

I'm having the same issue. I too tried the latest snapshot with no success. So unless someone comes up with a solid solution, I'm switching back to com.android.tools.build:gradle:1.3.1

marek-kuticka commented 8 years ago

Hi Thanos

can you confirm the issue is not present in 1.3.1 build tools?

thx a lot

Marek

2016-02-01 5:09 GMT+01:00 Thanos Psaridis (Fisherman) < notifications@github.com>:

I'm having the same issue. I too tried the latest snapshot with no success. So unless someone comes up with a solid solution, I'm switching back to com.android.tools.build:gradle:1.3.1

— Reply to this email directly or view it on GitHub https://github.com/groovy/groovy-android-gradle-plugin/issues/85#issuecomment-177753740 .

AndrewReitz commented 8 years ago

If you could provide a sample project that reproduces this issue I would better be able to help resolve it.

marek-kuticka commented 8 years ago

GroovyTest.zip Hello

attached see my project directory. I used just wizard to create android application with blank activity, then I added groovy functionality using gradle. now the error message is different from the one I got before, but still in same gradle task.

hope the sample project does help.

thx a lot Marek

ThanosFisherman commented 8 years ago

@marek-jasovsky I have no problems whatsoever using the 1.3.1 build tools. You might wanna try it

marek-kuticka commented 8 years ago

Hi Thanos, I have tried with 1.3.1 but no success. as this is gradle, what do I need in order for project structure to be correct? look in the zip above for another test project, as the original contains some pieces of code I cannot give out thx a lot, Marek

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
        classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'groovyx.grooid.groovy-android'

repositories {
    mavenLocal()
    jcenter()
}

android {
    compileSdkVersion 23
    buildToolsVersion '21.1.2'

    defaultConfig {
        applicationId "fxxx"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        debug {
            applicationIdSuffix '.dev'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    lintOptions {
        disable 'InvalidPackage' // lint sees references in the grooid jar to unavailable java classes
    }
    //packagingOptions {
        // workaround for http://stackoverflow.com/questions/20673625/android-gradle-plugin-0-7-0-duplicate-files-during-packaging-of-apk
        //exclude 'META-INF/LICENSE.txt'
        //exclude 'META-INF/groovy-release-info.properties'
    //}
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'org.bouncycastle:bcprov-jdk16:1.45'
    compile 'org.codehaus.groovy:groovy:2.4.5:grooid'
}
ThanosFisherman commented 8 years ago

I modified @marek-jasovsky sample project and this is the configuration that works well for me.

GroovyTestFixed.zip

marek-kuticka commented 8 years ago

thx. gonna try this. how to open it? import or open existing? and where was the conflict?

Marek

2016-02-01 17:27 GMT+01:00 Thanos Psaridis (Fisherman) < notifications@github.com>:

I modified @marek-jasovsky https://github.com/marek-jasovsky sample project and this is the configuration that works well for me.

GroovyTestFixed.zip https://github.com/groovy/groovy-android-gradle-plugin/files/112549/GroovyTestFixed.zip

— Reply to this email directly or view it on GitHub https://github.com/groovy/groovy-android-gradle-plugin/issues/85#issuecomment-178056068 .

marek-kuticka commented 8 years ago

Thx a lot for help to @ThanosFisherman 1.3.1. build tools works, and as the issue seems not to be related to this plugin, I am closing the ticket and thanks everyone once more for help!

Cheers, Marek