【问题标题】:sun.security.validator.ValidatorException while gradle syncsun.security.validator.ValidatorException while gradle sync
【发布时间】:2018-11-09 05:00:36
【问题描述】:

从星期一开始,我遇到了一个与 sun.security.ValidatorException 相关的问题。上周一之前一切正常。

例外是:
配置根项目“CoreApp”时出现问题。

无法解析配置“:classpath”的所有文件。 无法下载 gradle.jar (com.android.tools.build:gradle:3.1.2) 无法获取资源“https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.jar”。 无法 HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.jar'。 sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径 无法下载 sdk-common.jar (com.android.tools:sdk-common:26.1.2) 无法获取资源“https://jcenter.bintray.com/com/android/tools/sdk-common/26.1.2/sdk-common-26.1.2.jar”。 无法 HEAD 'https://jcenter.bintray.com/com/android/tools/sdk-common/26.1.2/sdk-common-26.1.2.jar'。 sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径 无法下载 sdklib.jar (com.android.tools:sdklib:26.1.2) 无法获取资源“https://jcenter.bintray.com/com/android/tools/sdklib/26.1.2/sdklib-26.1.2.jar”。 无法 HEAD 'https://jcenter.bintray.com/com/android/tools/sdklib/26.1.2/sdklib-26.1.2.jar'。 sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径

原因:无法找到请求目标的有效认证路径

我的应用级别 gradle 是:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {

        applicationId "com.package.app"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 2000044
        versionName "4.1.1"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "3g"
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //compile 'com.squareup.okhttp3:logging-interceptor:3.4.0'
    compile 'com.android.support:appcompat-v7:27.1.1'
    compile 'com.android.support:design:27.1.1'
    compile 'com.google.firebase:firebase-core:15.0.2'
    compile 'com.google.firebase:firebase-config:15.0.2'
    compile 'com.google.firebase:firebase-messaging:15.0.2'
    compile 'com.google.android.gms:play-services-tagmanager:15.0.2'
    compile 'com.google.android.gms:play-services-auth:15.0.0'
    compile 'com.google.android.gms:play-services-maps:15.0.0'
    compile 'com.google.android.gms:play-services-location:15.0.0'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    //compile 'com.google.firebase:firebase-crash:12.0.1'
    compile 'com.crashlytics.sdk.android:crashlytics:2.9.2'
    compile 'com.facebook.android:facebook-android-sdk:4.31.0'
    compile 'com.appsflyer:af-android-sdk:4.8.9@aar'
    compile 'com.android.installreferrer:installreferrer:1.0'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'

项目级别的 gradle 是:

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:3.2.1'
        classpath 'io.fabric.tools:gradle:1.25.1'

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

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

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

我不知道是什么问题。请帮助我由于此错误而无法开发。

【问题讨论】:

标签: java android android-studio gradle


【解决方案1】:

前段时间我遇到了类似的问题,我做了以下操作

  1. 确保您已禁用离线工作表单项目设置

  2. 如果您在 Windows 上工作,只需清除 gradle 缓存 (see this),然后同步项目。它应该可以工作。

【讨论】:

  • 对我不起作用。我已经删除了 .gradle chache 和 invalidat/restrat 但同样的问题
  • 谢谢,但我认为这不是 JDK 问题,因为我能够创建新项目并且它工作正常。我认为这是一个依赖问题,但不知道如何解决这个问题。
  • 您可能需要从失败的站点获取证书并将其导入您的 cacerts 文件。完成后,杀死所有 Gradle 守护程序并再次尝试构建。
【解决方案2】:

当我忘记在管理员模式下运行 IntelliJ 时,我有时会看到这种情况。在管理员模式下运行已经多次为我解决了这个问题。不知道为什么,但希望这对其他人有帮助。

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 2017-07-29
    • 2017-09-07
    • 2021-07-12
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    相关资源
    最近更新 更多