Flutter sms Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher

721 views Asked by At

I got this error while trying to run this code.

import 'package:flutter_sms/flutter_sms.dart';
import "dart:async";

String message = "This is a test message!";
List<String> recipents = ["6874171269", "5556787676"];

void _sendSMS(String message, List<String> recipents) async {
  String result = await sendSMS(message: message, recipients: recipents)
      .catchError((onError) {
    print(onError);
  });
  print(result);
}

void main() {
  _sendSMS(message, recipents);
}

What went wrong: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher. The following dependencies do not satisfy the required version: project ':flutter_sms' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

So i went to the build.gradle file.

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

My Kotlin version is aldready higher than 1.5.20. Still getting this error. How do i resolve this issue ?

2

There are 2 answers

1
SWEETSOOP On

The version in android/build_gradle of the flutter_sms package must be modified.

0
b.lopes On

So,

  1. find your package dependency: flutter_sms under flutter plugins
  2. open the build.gradle under flutter_sms-2.3.3/android
  3. force it to use ext.kotlin_version = '1.7.10'
  4. Now if you try for instance to build the APK it should work!