flutter Android Gradle插件仅支持KotlinGradle插件版本1.3.40及更高版本

2lpgd968  于 2023-05-18  发布在  Flutter
关注(0)|答案(5)|浏览(277)

当我运行应用程序时出现问题-
失败:生成失败,出现异常。

  • 出了什么问题:Android Gradle插件仅支持KotlinGradle插件1.3.40及更高版本。以下依赖项不满足所需的版本:项目':google_map_location_picker' -> org.jetbrains.Kotlin:kotlin-gradle-plugin:1.3.31
    我的项目环境--
version: 1.0.0+1

environment:
  sdk: ">=2.11.0 <3.0.0"
module:
  androidX: true
dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

系统安装Flutter SDK--

[√]Flutter通道稳定,3.0.5,
密码泄露了-

android/app- build.gradle

android {
    compileSdkVersion 31

    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 "indil.customer"
        minSdkVersion 21
        targetSdkVersion 31
        multiDexEnabled true
        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 {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
//            signingConfig signingConfigs.debug
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.firebase:firebase-messaging:20.1.7'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

android - build.gradle

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

    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.android.tools.build:gradle:7.0.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
3df52oht

3df52oht1#

在build.gradle中更改Kotlin版本
Android -构建.gradle

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

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

fkvaft9z2#

变化
“org.jetbrains.Kotlin:kotlin-stdlib-jdk7:$kotlin_version”
到此为止
org.jetbrains.Kotlin:kotlin-stdlib-jdk8:$kotlin_version

js81xvg6

js81xvg63#

Try this

   buildscript {
    ext.kotlin_version = '1.6.10' //-> add this
    repositories {
        google()
        mavenCentral()
    }

dependencies {
  classpath 'com.android.tools.build:gradle:4.1.3'
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"//->add this

}
7fyelxc5

7fyelxc54#

因为你必须在google_map_location_picker包的android文件夹中进行此更改

llycmphe

llycmphe5#

1.添加为其指定错误的Kotlin版本号
buildscript { ext.Kotlin_version = '1.6.20'//基于错误更改

repositories {
    google()
    jcenter()
}

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

}
1.清理项目cd android &&./gradlew清理&& cd../
1.构建项目

相关问题