Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find org.gradle.api.artifacts.result.ResolvedModuleVersionResult when apply Android plugin in Gradle

When I upgrade gradle to 1.10 in my Ubuntu 12.04, I can't build android gradle project, tell me Could not create plugin of type 'AppPlugin', debug message is like:

15:35:52.069 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.NoClassDefFoundError: org/gradle/api/artifacts/result/ResolvedModuleVersionResult
15:35:52.073 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.AppPlugin.$getStaticMetaClass(AppPlugin.groovy)
15:35:52.077 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.BasePlugin.<init>(BasePlugin.groovy:1627)
15:35:52.101 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.AppPlugin.<init>(AppPlugin.groovy:73)
15:35:52.105 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:62)
15:35:52.123 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.plugins.DefaultPluginRegistry.loadPlugin(DefaultPluginRegistry.java:67)
15:35:52.132 [ERROR] [org.gradle.BuildExceptionReporter]    ... 43 more
15:35:52.135 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.ClassNotFoundException: org.gradle.api.artifacts.result.ResolvedModuleVersionResult
15:35:52.157 [ERROR] [org.gradle.BuildExceptionReporter]    ... 48 more

Anybody can tell me how to fix this? or jsut Gradle 1.10 have some problems?

like image 878
Wangchao0721 Avatar asked Dec 28 '13 08:12

Wangchao0721


1 Answers

I found there is an issue in Android Open Source Project - Issue Tracker Issue #63822: Unable to load class 'org.gradle.api.artifacts.result.ResolvedModuleVersionResult'

reply by #1 [email protected]

It would seem Gradle 1.10 is not supported. Try using an older version of Gralde.

Notice that ResolvedModuleVersionResult is missing here

http://www.gradle.org/docs/1.10/javadoc/org/gradle/api/artifacts/result/package-summary.html

but is present here

http://www.gradle.org/docs/1.9/javadoc/org/gradle/api/artifacts/result/package-summary.html

So I downgrade my gradle to 1.9, it works again.

[Edit My Answer Here For How To Downgrade Gradle in Mac and Ubuntu]

For Mac: I use Homebrew, try Homebrew install specific version of formula?, I use 3.a historic times, works great for me.

For Ubuntu: If you already installed 1.10, try this:

# Install both gradle 1.9 and 1.10 on you ubuntu
sudo apt-get install gradle-1.9

# Check it to make sure
sudo update-alternatives --list gradle

# Config to choose gradle 1.9
sudo update-alternatives --config gradle
# Just select /usr/lib/gradle/1.9/bin/gradle to choose gradle 1.9
like image 170
Wangchao0721 Avatar answered Oct 21 '22 12:10

Wangchao0721