我正在尝试在Android Studio 3.0.1中导入一些源代码,但是出现以下错误:The app gradle file must have a dependency at org.gradle.tooling.internal.consume
我不知道问题出在哪里,尽管我获得了4.9的奖励
我的Gradle文件:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha06'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
maven { url "https://jitpack.io" }
maven { url 'http://guardian.github.com/maven/repo-releases' }
mavenCentral()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
整个错误报告:
错误:内部错误:org.gradle.tooling.BuildException:无法 使用Gradle分发执行构建 'https://services.gradle.org/distributions/gradle-4.9-all.zip'。在 org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51) 在 org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29) 在 org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41) 在 org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor $ 1 $ 1.run(DefaultAsyncConsumerActionExecutor.java:57) 在 org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 在 org.gradle.internal.concurrent.StoppableExecutorImpl $ 1.run(StoppableExecutorImpl.java:46) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 在 java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745)在 org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46) 在 org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:77) 在 com.android.tools.idea.gradle.project.build.invoker.GradleTasksExecutorImpl.lambda $ invokeGradleTasks $ 2(GradleTasksExecutorImpl.java:373) 在 org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:218) 在 com.android.tools.idea.gradle.project.build.invoker.GradleTasksExecutorImpl.invokeGradleTasks(GradleTasksExecutorImpl.java:426) 在 com.android.tools.idea.gradle.project.build.invoker.GradleTasksExecutorImpl.run(GradleTasksExecutorImpl.java:209) 在 com.intellij.openapi.progress.impl.CoreProgressManager $ TaskRunnable.run(CoreProgressManager.java:726) 在 com.intellij.openapi.progress.impl.CoreProgressManager.lambda $ runProcess $ 1(CoreProgressManager.java:176) 在 com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:556) 在 com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501) 在 com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66) 在 com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:163) 在 com.intellij.openapi.progress.impl.ProgressManagerImpl $ 1.run(ProgressManagerImpl.java:137) 在 com.intellij.openapi.application.impl.ApplicationImpl $ 2.run(ApplicationImpl.java:334) 在 java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511) 在java.util.concurrent.FutureTask.run(FutureTask.java:266)在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 在 java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745)造成原因: org.gradle.internal.exceptions.LocationAwareException:执行 任务':app:processDebugGoogleServices'失败。在 org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74) 在 org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:49) 在 org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:39) 在 org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30) 在 org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149) 在 org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:121) 在 org.gradle.internal.invocation.GradleBuildController $ 1.call(GradleBuildController.java:77) 在 org.gradle.internal.invocation.GradleBuildController $ 1.call(GradleBuildController.java:74) 在 org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152) 在 org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:38) 在 org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:96) 在 org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:74) 在 org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:55)
答案 0 :(得分:1)
使用gradle 4.4-all版本将Android Gradle插件版本更改为3.1.4
顶级构建文件:buildscript:
classpath 'com.android.tools.build:gradle:3.1.4'
gradle-wrapper.properties文件
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip