当前位置: 首页 > 面试题库 >

Android Studio 3.1.3 Gradle同步错误。无法下载Gradle-Core.jar

曾飞雨
2023-03-14
问题内容

我试图熟悉夏季爱好的构建应用程序。但是,在过去几天中,当我尝试同步Gradle时,出现了相同的错误,指出

gradle-core.jar无法下载。

我将在这篇文章的底部发布完整的错误消息。

当然,我确保我不在离线模式下工作。最重要的是,我强迫https://使用来获取源http://。我还将文件中https://distributionUrl 更改为http:// gradle-wrapper.properties。我尝试了不同的代理,并已将build.gradle文件中的存储库更改为jcenter(), mavenCentral(), and google().

我什至尝试与防火墙同步,并且防病毒功能已关闭,但没有任何作用。在下面,你将找到我的整个错误消息。

org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'AndroidStudioProjects'.
...
    at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:64)
    ... 84 more
Caused by: org.gradle.internal.resolve.ArtifactResolveException: Could not download gradle-core.jar (com.android.tools.build:gradle-core:3.1.3)
    at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveArtifact(ExternalResourceResolver.java:506)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$ResolveAndCacheRepositoryAccess.resolveArtifact(CachingModuleComponentRepository.java:409)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.BaseModuleComponentRepositoryAccess.resolveArtifact(BaseModuleComponentRepositoryAccess.java:65)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedModuleComponentRepository$CachedAccess.resolveArtifact(InMemoryCachedModuleComponentRepository.java:124)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.resolveArtifact(ErrorHandlingModuleComponentRepository.java:171)
    ...
    ... 6 more
Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-core/3.1.3/gradle-core-3.1.3.jar'.
    at org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:74)
    at org.gradle.internal.resource.ResourceExceptions.getFailed(ResourceExceptions.java:57)
    at org.gradle.internal.resource.transfer.AccessorBackedExternalResource.withContentIfPresent(AccessorBackedExternalResource.java:146)
    ...
    at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveArtifact(ExternalResourceResolver.java:499)
    ... 27 more
Caused by: javax.net.ssl.SSLException: SSL peer shut down incorrectly
    at sun.security.ssl.InputRecord.readV3Record(InputRecord.java:596)
    at sun.security.ssl.InputRecord.read(InputRecord.java:532)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
    at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
    at org.apache.http.impl.io.SessionInputBufferImpl.read(SessionInputBufferImpl.java:200)
    ...
    at org.gradle.internal.resource.transfer.AccessorBackedExternalResource.withContentIfPresent(AccessorBackedExternalResource.java:137)
    ... 44 more

(编辑):以下是我的相关文件

build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        jcenter()
        mavenCentral()
        google()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

gradle-wrapper.properties:

#Tue Jun 26 21:50:19 MDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-4.4-all.zip 

gradle.properties:

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

settings.gradle:

include ':app'

local.properties:

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=C\:\\Users\\jddah\\AppData\\Local\\Android\\Sdk

问题答案:

尝试将以下内容google()作为第一个回购。不要把它放在jcenter()mavenCentral()你现有的Android Studio项目。

repositories {
    google() // make this repo as the first one if Android Gradle Plugin is upgraded from 2.x to 3.x. 
    jcenter()
    mavenCentral()
}

对于使用Android Gradle Plugin较低版本(例如2.2.3)的React Native或CordovaLib项目,你可以尝试将其替换为google()以下内容,但请记住将其作为第一个回购选择。

repositories {
    // google()
    maven {
        url "https://maven.google.com"
    }
    jcenter()
}

清理所有旧.gradle缓存,然后执行新的同步。



 类似资料:
  • 我是一名计算机科学专业的学生,我正试图通过暑期爱好熟悉建筑应用程序。然而,在过去的几天里,当我尝试同步Gradle时,它会给我同样的错误,说明 无法下载gradle-core.jar。 我将在这篇文章的底部发布完整的错误消息。 当然,我确保我没有在离线模式下工作。最重要的是,我强制使用超文本传输协议获取源。我还改变了为分发Url超文本传输协议://在文件。我尝试了不同的代理,并将文件中的存储库更改

  • 我使用的是Android studio 1.3.1,无法同步Gradle项目错误: 我默认的和仍然显示这个错误,有人能告诉我为什么我得到这个错误吗?

  • 驴你看,我要添加截取到我的应用程序添加这行代码com.mcxioke。截取:库aar:1.0.0建立。gradle文件 我也试着添加改装。但它给出了相同类型的错误:未能解决:bla bla bla。 所以我认为在我的情况下gradle不能同步任何其他库不同于com.android....... 我也尝试将这行代码添加到我的build.gradle。但是什么都没有改变 请指教 编辑:添加注释后生成。

  • 当我运行我的项目时,出现“系统找不到指定的路径”错误。我最近也做了系统还原 从渐变同步刷新渐变“游戏”项目失败

  • 我正在尝试添加以下依赖项:

  • 今天早上,所有Android Studio项目开始失败Gradle Sync/Build/Clean: stacktrace看起来像: