When I try to run my flutter app on android device from android studio I’m getting this error: minSdkVersion 16 cannot be smaller than version 19 declared in library [:flutter_blue], I know what I have to do is add:
defaultConfig {
minSdkVersion 19
}
I added this line in the build.gradle file but I’m still getting the same error, also I have in my pubspec.yaml my dependencie like this:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
flutter_blue: ^0.8.0
this is my flutter version:
Flutter 3.7.10 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 4b12645012 (11 days ago) • 2023-04-03 17:46:48 -0700
Engine • revision ec975089ac
Tools • Dart 2.19.6 • DevTools 2.20.1
Dart sdk version: Dart SDK version: 2.19.6 (stable) (Tue Mar 28 13:41:04 2023 +0000) on "windows_x64"
.
When I run the flutter doctor command everything is ok.
I don’t know if I’m missing something, also I created the issue in https://github.com/pauldemarco/flutter_blue directly.To take into account: I can run the same app on iPhone without problems from visual studio code
2
Answers
I found the problem, it was in the build.gradle file,I had the default config like this:
after the line minSdkVersion 19 I had another line minSdkVersion with this value flutter.minSdkVersion,I didn´t know that this value is set up on my pubspec.yaml in the flutter section, like this:
if we don't have this value flutter takes the default min value that is 16, so you can put this value on the pubSpec.yaml or you can delete the second line on the build.gradle file
Make sure you have updated correct build.gradle file, it should be in the app directory. Example for how this should look like:
If that is correct you may refresh flutter dependencies: