Gradle Experimental Plugin Android error: Cannot invoke method dependencies()

Update: Engineers at Google fixed the issue. Thank you.

After initial setup of SDL2 application for Android, I decided to add one activity before launching SDL. So I created the new MainActivity which should launch SDLActivity after a tap on the button.

This time Gradle Experimental Plugin gave me a very fancy error: Cannot invoke method dependencies() on null object.

As always the error message does not provide too many hints how to solve the issue.

Android Studio automatically just appended a dependency into the Gradle file during creation of new MainActivity. So the code in build.gradle looked like this:

tasks.whenTaskAdded { task ->
    if (task.name.contains('compile')) {
        task.dependsOn ':main:distributeLib'
    }
}dependencies {
    compile 'com.android.support.constraint:constraint-layout:+'
}

Little bit weird code for dependencies. The solution was just to add a new line.

tasks.whenTaskAdded { task ->
    if (task.name.contains('compile')) {
        task.dependsOn ':main:distributeLib'
    }
}

dependencies {
    compile 'com.android.support.constraint:constraint-layout:+'
}

The whole project is available at github.com/georgik/sdl2-android-example project.

More articles about SDL2 for Android are available under tag sdl2.

7. September 2017 at 20:32 - Development (Tags: , , , , ). Both comments and pings are currently closed.

Comments are closed.