gradle 无法解析配置的任何依赖项:classpath
Posted
技术标签:
【中文标题】gradle 无法解析配置的任何依赖项:classpath【英文标题】:gradle can not resolve any dependency for configuration: classpath 【发布时间】:2021-03-21 11:24:06 【问题描述】:我所有使用 gradle builder 的项目都有这个错误。 gradle 无法同步,并且没有任何依赖关系解决。 这是错误: 无法解析配置“:classpath”的所有工件。
找不到 com.android.tools.build:gradle:6.7.1。 在以下位置搜索: - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/6.7.1/gradle-6.7.1.pom - https://jcenter.bintray.com/com/android/tools/build/gradle/6.7.1/gradle-6.7.1.pom - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/6.7.1/gradle-6.7.1.pom 要求: 项目 : 找不到 android.arch.navigation:navigation-safe-args-gradle-plugin:2.3.0。 在以下位置搜索: - https://dl.google.com/dl/android/maven2/android/arch/navigation/navigation-safe-args-gradle-plugin/2.3.0/navigation-safe-args-gradle-plugin-2.3.0.pom - https://jcenter.bintray.com/android/arch/navigation/navigation-safe-args-gradle-plugin/2.3.0/navigation-safe-args-gradle-plugin-2.3.0.pom - https://repo.maven.apache.org/maven2/android/arch/navigation/navigation-safe-args-gradle-plugin/2.3.0/navigation-safe-args-gradle-plugin-2.3.0.pom 要求: 项目 : 可能的解决方案:
声明提供工件的存储库,请参阅https://docs.gradle.org/current/userguide/declaring_repositories.html 上的文档
这是我的 build.gradle 文件:
buildscript
repositories
google()
jcenter()
mavenCentral()
dependencies
classpath 'com.android.tools.build:gradle:6.7.1'
classpath 'android.arch.navigation:navigation-safe-args-gradle-plugin:2.3.0'
allprojects
repositories
google()
jcenter()
task clean(type: Delete)
delete rootProject.buildDir
这是我的 :app build.gradle 文件
apply plugin: 'com.android.application'
apply plugin: 'androidx.navigation.safeargs'
android
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig
applicationId "com.example.jartest2"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
dependencies
def nav_version = "2.3.0"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
implementation "androidx.navigation:navigation-runtime:$nav_version"
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
这是日志文件:
INFO - j.ide.actions.RevealFileAction - Exit code 1
2020-12-10 05:19:12,205 [47703891] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:12,596 [47704282] INFO - rationStore.ComponentStoreImpl - Saving Project(name=JarTest2, containerState=COMPONENT_CREATED, componentStore=D:\computer\Java\IdeaProjects\JarTest2)JavacSettings took 16 ms 2020-12-10 05:19:12,706 [47704392] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:22,712 [47714398] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:23,226 [47714912] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:24,230 [47715916] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:24,746 [47716432] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:25,754 [47717440] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:26,263 [47717949] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:26,779 [47718465] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:27,294 [47718980] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:27,810 [47719496] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:28,326 [47720012] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:28,838 [47720524] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:29,344 [47721030] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:29,846 [47721532] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:30,354 [47722040] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:30,870 [47722556] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:31,385 [47723071] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:31,901 [47723587] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:31,932 [47723618] INFO - System.util.ExternalSystemUtil - External project [D:/computer/Java/IdeaProjects/JarTest2] resolution task started` 2020-12-10 05:19:32,010 [47723696] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Program Files/Java/jdk1.8.0_72 2020-12-10 05:19:32,010 [47723696] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Program Files/Java/jdk1.8.0_72 2020-12-10 05:19:32,042 [47723728] INFO - oject.common.GradleInitScripts - init script file sync.studio.tooling contents "initscript \n dependencies \n classpath files(['C:\\\\Program Files\\\\JetBrains\\\\IntelliJ IDEA Community Edition 2020.3\\\\plugins\\\\android\\\\lib\\\\android.jar', 'C:\\\\Program Files\\\\JetBrains\\\\IntelliJ IDEA Community Edition 2020.3\\\\plugins\\\\android\\\\lib\\\\android.jar', 'C:\\\\Program Files\\\\JetBrains\\\\IntelliJ IDEA Community Edition 2020.3\\\\lib\\\\kotlin-stdlib-1.4.0.jar'])\n \n\nallprojects \n apply plugin: com.android.ide.gradle.model.builder.AndroidStudioToolingPlugin\n\n" 2020-12-10 05:19:32,057 [47723743] INFO - xecution.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: -Didea.sync.active=true -Didea.resolveSourceSetDependencies=true -Porg.gradle.kotlin.dsl.provider.cid=47899959731139 --init-script C:\Users\M.H\AppData\Local\Temp\sync.studio.tooling11867.gradle -Djava.awt.headless=true --stacktrace -Pandroid.injected.build.model.only=true -Pandroid.injected.build.model.only.advanced=true -Pandroid.injected.invoked.from.ide=true -Pandroid.injected.build.model.only.versioned=3 -Pandroid.injected.studio.version=10.4.0.203.5981.155 -Pandroid.injected.build.model.disable.src.download=true -Pidea.gradle.do.not.build.tasks=false --init-script C:\Users\M.H\AppData\Local\Temp\ijinit5.gradle 2020-12-10 05:19:32,409 [47724095] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:32,925 [47724611] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:42,652 [47734338] INFO - .project.GradleProjectResolver - Gradle project resolve error org.gradle.tooling.GradleConnectionException: Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.7.1-all.zip'.
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55)
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:43)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:69)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:834) Caused by: org.gradle.api.UncheckedIOException: java.io.StreamCorruptedException: invalid type code: 00
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:61)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
at org.gradle.tooling.internal.provider.serialization.PayloadSerializer.deserialize(PayloadSerializer.java:78)
at org.gradle.tooling.internal.provider.ProviderConnection.throwFailure(ProviderConnection.java:231)
at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:219)
at org.gradle.tooling.internal.provider.ProviderConnection.runPhasedAction(ProviderConnection.java:179)
at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.java:245)
at org.gradle.tooling.internal.consumer.connection.PhasedActionAwareConsumerConnection.run(PhasedActionAwareConsumerConnection.java:56)
at org.gradle.tooling.internal.consumer.connection.ParameterValidatingConsumerConnection.run(ParameterValidatingConsumerConnection.java:62)
at org.gradle.tooling.internal.consumer.DefaultPhasedBuildActionExecuter$1.run(DefaultPhasedBuildActionExecuter.java:78)
at org.gradle.tooling.internal.consumer.DefaultPhasedBuildActionExecuter$1.run(DefaultPhasedBuildActionExecuter.java:70)
at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:130)
at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45)
at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:61)
at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:67)
... 6 more Caused by: java.io.StreamCorruptedException: invalid type code: 00
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1710)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.readArray(ObjectInputStream.java:2102)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1667)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:493)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:451)
at org.gradle.tooling.internal.provider.serialization.PayloadSerializer.deserialize(PayloadSerializer.java:76)
... 19 more 2020-12-10 05:19:42,663 [47734349] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Program Files/Java/jdk1.8.0_72 2020-12-10 05:19:42,665 [47734351] INFO - g.jetbrains.kotlin.idea.script - [KOTLIN_SCRIPTING] IllegalStateException loading gradle script templates: Unable to get Gradle home directory 2020-12-10 05:19:42,668 [47734354] INFO - g.jetbrains.kotlin.idea.script - [KOTLIN_SCRIPTING] Cannot find valid gradle home for null with version = null, script models cannot be saved 2020-12-10 05:19:42,669 [47734355] INFO - System.util.ExternalSystemUtil - External project [D:/computer/Java/IdeaProjects/JarTest2] resolution task executed in 10737 ms. 2020-12-10 05:19:42,961 [47734647] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:43,067 [47734753] INFO - ge.ExternalProjectsDataStorage - Save external projects data in 46 ms 2020-12-10 05:19:43,462 [47735148] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:43,963 [47735649] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:44,467 [47736153] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:44,983 [47736669] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:45,487 [47737173] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:45,992 [47737678] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:46,487 [47738173] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:47,518 [47739204] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:52,052 [47743738] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:55,073 [47746759] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:55,588 [47747274] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:56,104 [47747790] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:56,620 [47748306] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:57,128 [47748814] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:57,630 [47749316] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:02,671 [47754357] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:03,678 [47755364] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:04,175 [47755861] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:09,781 [47761467] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:10,278 [47761964] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:10,778 [47762464] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:11,282 [47762968] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:12,282 [47763968] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:12,785 [47764471] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:13,287 [47764973] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:13,787 [47765473] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:14,291 [47765977] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:14,806 [47766492] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:15,322 [47767008] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:15,822 [47767508] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:16,338 [47768024] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:16,853 [47768539] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:17,360 [47769046] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:17,861 [47769547] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:19,365 [47771051] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:19,881 [47771567] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:21,420 [47773106] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:21,921 [47773607] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:22,421 [47774107] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:22,921 [47774607] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:23,418 [47775104] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:23,780 [47775466] INFO - rationStore.ComponentStoreImpl - Saving appLangManager took 16 ms 2020-12-10 05:20:23,921 [47775607] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:28,929 [47780615] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:56,843 [47808529] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:20:57,358 [47809044] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:21:05,930 [47817616] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:21:06,430 [47818116] INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:22:26,483 [47898169] INFO - .deployment.AsyncDevicesGetter - adb not found
我检查了互联网连接。它工作正常。在我使用代理但仍然有这个错误之后。我将我的 intellij 更新为 11.0.9,将 java 更新为 10,但没有帮助。我检查了 JAVA_HOME 路径,它已正确定义。我删除用户主页中的 .gradle 文件夹并使缓存无效并重新启动并再次构建项目,但它也无济于事。 现在我使用的是 Windows 10、intellij IDEA 11.0.9 和 jdk 1.8。任何帮助将不胜感激。
【问题讨论】:
【参考方案1】:搜索后发现问题出在代理上。我更改了代理服务器,gradle 工作正常!
【讨论】:
以上是关于gradle 无法解析配置的任何依赖项:classpath的主要内容,如果未能解决你的问题,请参考以下文章
同步 gradle 的问题:无法解析外部依赖项 com.android.tools.build:gradle,因为没有定义存储库
无法将 git 存储库解析为 android gradle 中的依赖项
Gradle 构建无法解析所有 Path_provider 依赖项
在最后一个 gradle 版本中无法解析 android studio 中的 jitpack 依赖项
无法解析配置':app:debugCompileClasspath的所有依赖项
将 Android Studio 的 Gradle 插件升级到 3.0.1 和 Gradle 到 4.1 后无法复制配置依赖项