当我尝试在Android Studio中构建时,我今天收到错误:
11:32:11 AM Gradle '...' project refresh failed:
Cause: com.android.sdklib.SdkManager.createManager(Ljava/lang/String;Lcom/android/utils/ILogger;)Lcom/android/sdklib/SdkManager;
Gradle settings
当我尝试./gradlew compileDebug --stacktrace时,我得到:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project '...'.
> java.lang.NoSuchMethodError: com.android.sdklib.SdkManager.createManager(Ljava/lang/String;Lcom/android/utils/ILogger;)Lcom/android/sdklib/SdkManager;
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project '...'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:507)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:82)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:46)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:37)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:58)
Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NoSuchMethodError: com.android.sdklib.SdkManager.createManager(Ljava/lang/String;Lcom/android/utils/ILogger;)Lcom/android/sdklib/SdkManager;
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy15.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
... 29 more
Caused by: java.lang.NoSuchMethodError: com.android.sdklib.SdkManager.createManager(Ljava/lang/String;Lcom/android/utils/ILogger;)Lcom/android/sdklib/SdkManager;
at com.android.builder.DefaultSdkParser.initParser(DefaultSdkParser.java:78)
at com.android.builder.SdkParser$initParser.call(Unknown Source)
at com.android.build.gradle.internal.Sdk.loadParser(Sdk.groovy:126)
at com.android.build.gradle.internal.Sdk$loadParser.call(Unknown Source)
at com.android.build.gradle.BasePlugin.getLoadedSdkParser(BasePlugin.groovy:309)
at com.android.build.gradle.BasePlugin.getRuntimeJarList(BasePlugin.groovy:354)
at com.android.build.gradle.BasePlugin.createProguardTasks(BasePlugin.groovy:1521)
at com.android.build.gradle.BasePlugin.addPackageTasks(BasePlugin.groovy:1212)
at com.android.build.gradle.AppPlugin.createApplicationVariant(AppPlugin.groovy:607)
at com.android.build.gradle.AppPlugin.this$3$createApplicationVariant(AppPlugin.groovy)
at com.android.build.gradle.AppPlugin.createTasksForDefaultBuild(AppPlugin.groovy:351)
at com.android.build.gradle.AppPlugin.doCreateAndroidTasks(AppPlugin.groovy:202)
at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.groovy:280)
at com.android.build.gradle.BasePlugin$_apply_closure1.doCall(BasePlugin.groovy:223)
... 36 more
BUILD FAILED
Total time: 8.585 secs
此错误发生在0.4.0上,更新到0.4.2没有修复它。这是我的build.gradle的一部分:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
maven { url 'http://download.crashlytics.com/maven' }
}
//noinspection GroovyAssignabilityCheck
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.9'
}
我昨天能够构建,从那时起代码没有改变 - 我工作的人能够使用相同的代码在他的机器上构建。有什么想法吗?
答案 0 :(得分:4)
使用gradle或gradle包装器,但是你有项目设置,刷新依赖项似乎已经为我解决了这个问题。
[gradle | ./gradlew] - refresh-dependencies&& [gradle | ./gradlew]汇编[Debug | Release]