使用 Gradle 升级到 1.10 版本,编译 Android 项目的时候报告类似如下的异常信息
1 2 3 4 5 6 7 8 9 |
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 |
搜索了一下,找到答案如下
1 2 3 4 5 |
请注意 ResolvedModuleVersionResult 是丢失在这里 http://www.gradle.org/docs/1.10/javadoc/org/gradle/api/artifacts/result/package-summary.html 但这里存在 http://www.gradle.org/docs/1.9/javadoc/org/gradle/api/artifacts/result/package-summary.html 所以降级到 1.9 就可以了 |
也就是说Gradle 1.9 以上的版本编译 Android 代码目前是存在问题的。