构建Andorid应用程序时Flutter Gradle SSL异常

时间:2019-12-05 14:23:58

标签: android gradle flutter

我收到SSL异常,例如PKIX路径构建失败:

我尝试手动添加Jcenter和Gradle证书。但仍然会出现错误。

请帮助。 我正在使用最新的Mac OS Catalina。


android> build.gradle

    ext.kotlin_version = '1.3.61'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
    }
}

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

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

app> build.gradle

def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.marhaba_app"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
        }
        }
        buildTypes {
            release {
                signingConfig signingConfigs.release
                minifyEnabled true
                useProguard true

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
            }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

apply plugin: 'com.google.gms.google-services'

尝试使用Flutter构建android应用时获取SSL异常

异常:

* Error running Gradle:
           ProcessException: Process
"/Users/burhanuddin/Documents/Burhanuddin/Flutter/marhaba_app/android/gradlew"
           exited abnormally:

           FAILURE: Build failed with an exception.

           * What went wrong:
           A problem occurred configuring root project 'android'.
           > Could not resolve all artifacts for configuration ':classpath'.
              > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61.
                Required by:
                    project :
                 > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61.
                    > Could not get resource

'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.61/kotlin-gradle-plu
                    gin-1.3.61.pom'.
                       > Could not HEAD

'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.61/kotlin-gradle-
                       plugin-1.3.61.pom'.
                          > sun.security.validator.ValidatorException: PKIX path building failed:
                          sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid
                          certification path to requested target
              > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11.
                Required by:
                    project : > com.android.tools.build:gradle:3.2.1
                    project : > com.android.tools.build:gradle:3.2.1 >
com.android.tools.build:builder:3.2.1
                    project : > com.android.tools.build:gradle:3.2.1 >
                    com.android.tools.lint:lint-gradle-api:26.2.1
                    project : > com.android.tools.build:gradle:3.2.1 >
com.android.tools.build:gradle-api:3.2.1
                    project : > com.android.tools.build:gradle:3.2.1 >
                    androidx.databinding:databinding-compiler-common:3.2.1
                    project : > com.android.tools.build:gradle:3.2.1 >
com.android.tools.build:builder:3.2.1 >
                    com.android.tools:sdk-common:26.2.1
                    project : > com.android.tools.build:gradle:3.2.1 >
com.android.tools.build:builder:3.2.1 >
                    com.android.tools:common:26.2.1
                    project : > com.android.tools.build:gradle:3.2.1 >
com.android.tools.build:builder:3.2.1 >
                    com.android.tools.build:manifest-merger:26.2.1
                    project : > com.android.tools.build:gradle:3.2.1 >
com.android.tools.build:builder:3.2.1 >
                    com.android.tools:sdklib:26.2.1 > com.android.tools:repository:26.2.1
                 > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11.
                    > Could not get resource

0 个答案:

没有答案