android - 错误:Android Gradle插件仅支持Kotlin Gradle插件1.3.10及更高版本

标签 android kotlin gradle

我在代码中使用“flutter_launch 0.2.0”时出现以下错误

import 'package:flutter/material.dart';
import 'package:flutter_launch/flutter_launch.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  initState() {
    super.initState();
  }

  void whatsAppOpen() async {
    await FlutterLaunch.launchWathsApp(phone: "5534992016545", message: "Hello");
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app'),
        ),
        body: new Center(
          child: FlatButton(
            child: Text("Open WhatsApp"),
            onPressed: () {
              whatsAppOpen();
            },
          )
        ),
      ),
    );
  }
}

失败:生成失败,发生异常。
  • 出了什么问题:
    Android Gradle插件仅支持Kotlin Gradle插件1.3.10及更高版本。
    以下依赖项不满足要求的版本:
    项目':flutter_launch'-> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71
  • 尝试:
    使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行,以获取更多日志输出。与--scan一起运行以获取完整的见解。
  • https://help.gradle.org上获得更多帮助

  • 2秒内失败
    异常:Gradle任务assembleDebug失败,退出代码为1

    我的 Kotlin 课是这个
    buildscript {
    ext.kotlin_version = '1.3.10'
    repositories {
        google()
        jcenter()
    }
    
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
    }
    

    }

    请告诉我为什么会这样。

    最佳答案

  • 升级 kotlin-gradle-plugin 版本
  • 升级 build:gradle 版本

  • DEMO
     buildscript {
        ext.kotlin_version = '1.3.72'
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.6.3'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.3.3'
        }
      }
    

    并打开 gradle-wrapper.properties 并升级gradle版本。
    distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
    

    关于android - 错误:Android Gradle插件仅支持Kotlin Gradle插件1.3.10及更高版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62319285/

    相关文章:

    android - 使用以下命令时,Android资源链接失败:buildFeatures {viewBinding = true}

    android - 使用必应拼写检查 API 的空响应

    java - Kotlin 扩展属性

    android - 减少撰写按钮内的填充

    kotlin - 在自定义任务的子项目中运行 gradle build(test)

    android - Android Studio app.gradle错误:程序类型已存在:android.support.v4.app.BackStackRecord $ Op

    java - 在 TextView 中显示评论/在编辑 View 中接受评论以在测验应用程序中使用

    java - 在不使用 Dagger 的情况下使用 Espresso ActivityTestRule 初始化时模拟 Activity 的 onCreate

    安卓穿戴包装

    android - 如何在 android 中模拟 Kotlin 对象?