Android Studio / gradle: "Failed to create a plugin like" LibraryPlugin ""

I have two modules in Android Studio.

Main is an application, and Sub is a library module. Sub is passed from Main with compile project(':Sub') to the gradle script. This works when launched from Android Studio. But when launched from the command line, gradlew says:

 Could not create plugin of type 'LibraryPlugin'. Caused by: java.lang.NoClassDefFoundError: org/gradle/api/artifacts/result/ResolvedComponentResult 

These are the important parts in the Main build.gradle file:

 apply plugin: 'android' buildscript { repositories { mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.9.+' } } repositories { mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } task wrapper(type: org.gradle.api.tasks.wrapper.Wrapper) { gradleVersion = '1.11' } android { buildToolsVersion '19.0.3' } dependencies { compile 'com.android.support:support-v4:13.0.+' compile project (':Sub') } 

The sub gradle file is more or less identical, but has

 apply plugin: 'android-library' 

instead of 'android'

I tried with gradle 1.9 and 1.10, but the same result.

Does anyone know how to solve this?

+7
android-studio gradle
source share
1 answer

Make sure your dependencies contain the classpath 'com.android.tools.build:gradle:0.9.+' in each gradle.build file (or just put it in the base, and not declare in others). Update gradle/wrapper/gradle-wrapper.properties to point to gradle 1.11:

 distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip 

If you have other instances of gradle -wrapper (for example, if you created a library project yourself and then added an example application), make sure that all instances are updated to point to the same version (each gradle-wrapper.properties file).

+4
source share

All Articles