Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio gradle can't import groovy.swing.SwingBuilder

I'm using this technique to make release builds ask for keystore passwords, but lately the Android Studio editor for build.gradle complains:

Cannot resolve symbol 'groovy'

for the line:

import groovy.swing.SwingBuilder

It didn't used to complain. The command line build ./gradlew assembleRelease still works. It's only AS that can't import groovy.

This is with Android Studio 2.3.1, Gradle 3.3, Android Gradle plugin 2.3.1.

Is there some AS configuration to make it happy?

Amazingly enough, the import error doesn't keep AS from making debug builds, and build.gradle doesn't try to use Swing in a debug build.

like image 674
Jerry101 Avatar asked Apr 15 '17 07:04

Jerry101


1 Answers

Starting with Gradle 6.x, gradle no longer embeds a copy of groovy-all, so groovy-swing is not included. https://docs.gradle.org/current/userguide/upgrading_version_6.html#groovy_modularization

This can be solved by adding e.g. org.codehaus.groovy:groovy-swing:3.0.9 to your buildscript in your top-level build.gradle file.

buildscript {
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'
        classpath 'org.codehaus.groovy:groovy-swing:3.0.9'
    }
}
like image 200
acoder Avatar answered Oct 15 '22 12:10

acoder