简体   繁体   English

在 android studio 中更新 kotlin 插件后 Flutter 构建失败

[英]Flutter build faild after updating kotlin plugin in android studio

last week i updated Kotlin IDE plugin in android studio IDE but after that my flutter project faild to build to debugin or release i face this error, i thought android studio is the problem but vscode is the same result so after googling in 7 days i tried many solutions but im facing new errors so this the first error and original gradle config , i hope to find solution here thank you FAILURE: Build failed with an exception.上周我在 android studio IDE 中更新了 Kotlin IDE 插件,但在那之后我的 Flutter 项目无法构建调试或发布我遇到这个错误,我认为 android studio 是问题但 vscode 是相同的结果,所以在谷歌搜索后 7 天我试过了许多解决方案,但我面临新的错误,所以这是第一个错误和原始 gradle 配置,我希望在这里找到解决方案谢谢失败:构建失败并出现异常。

* What went wrong:
Could not determine the dependencies of task ':app:dataBindingMergeDependencyArtifactsDebug'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve net.minidev:json-smart:[1.3.1,2.3].
     Required by:
         project :app > project :stripe_payment > com.stripe:stripe-android:10.4.6 > com.stripe:stripe-3ds2-android:1.2.2 > com.nimbusds:nimbus-jose-jwt:7.8
      > Failed to list versions for net.minidev:json-smart.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/net/minidev/json-smart/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/net/minidev/json-smart/maven-metadata.xml'.
               > org.apache.http.client.ClientProtocolException (no error message)31

android\vuild.gradle android\vuild.gradle

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

    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
        // Add the google services classpath
        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应用程序\build.gradle

def localProperties = new Properties()
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 = '2'
}

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

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


/*def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))*/

android {
    compileSdkVersion 30

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

    lintOptions {
        disable 'InvalidPackage'
        checkReleaseBuilds false
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "at.info.fity"
        minSdkVersion 26
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    /*signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
*/
    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
//            signingConfig signingConfigs.release
            signingConfig signingConfigs.debug
        }
    }
    buildFeatures {
        viewBinding true
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-messaging:20.1.3'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
    implementation 'com.android.volley:volley:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.android.gms:play-services-fitness:18.0.0'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.github.orangegangsters:sensorstep:1.4.2@aar'
    implementation 'com.squareup.moshi:moshi-kotlin:1.9.3'
    implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'


}

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

gradle distributions : distributions/gradle-6.5-all gradle 发行版:distributions/gradle-6.5-all

updated plugin is IDE plugin更新的插件是 IDE 插件

在此处输入图像描述

i solved the problem with add constraints off json-smart to :我通过在 json-smart 中添加约束解决了这个问题:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-messaging:20.1.3'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
    implementation 'com.android.volley:volley:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.android.gms:play-services-fitness:18.0.0'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.github.orangegangsters:sensorstep:1.4.2@aar'
    implementation 'com.squareup.moshi:moshi-kotlin:1.9.3'
    implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
}

after :后 :

dependencies {
    constraints { implementation('net.minidev:json-smart') { version { strictly '2.3.1' } } }
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-messaging:20.1.3'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
    implementation 'com.android.volley:volley:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.android.gms:play-services-fitness:18.0.0'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.github.orangegangsters:sensorstep:1.4.2@aar'
    implementation 'com.squareup.moshi:moshi-kotlin:1.9.3'
    implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM