1

I wrote a code like this:

main.dart:

import 'package:flutter/material.dart';
import 'package:flutter_sms_inbox/flutter_sms_inbox.dart';
import 'package:permission_handler/permission_handler.dart';

void main() {
  runApp(Main());
    SmsQuery query = SmsQuery();
}
class Main extends StatefulWidget {
  const Main({Key? key}) : super(key: key);

  @override
  State<Main> createState() => _MainState();
}

class _MainState extends State<Main> {
  final SmsQuery _query = SmsQuery();
  List<SmsMessage> _messages = [];
  @override
  void initState() {
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Container(
          padding: const EdgeInsets.all(10.0),
          child: ListView.builder(
            shrinkWrap: true,
            itemCount: _messages.length,
            itemBuilder: (BuildContext context, int i) {
              var message = _messages[i];
              return ListTile(
                title: Text('${message.sender} [${message.date}]'),
                subtitle: Text('${message.body}'),
              );
            },
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () async {
            var permission = await Permission.sms.status;
            if (permission.isGranted) {
              final messages = await _query.querySms(
                kinds: [SmsQueryKind.inbox, SmsQueryKind.sent],
                // address: '+254712345789',
                count: 10,
              );
              debugPrint('sms inbox messages: ${messages.length}');
              setState(() => _messages = messages);
            } else {
              await Permission.sms.request();
            }
          },
          child: const Icon(Icons.refresh),
        ),
      ),
    );
  }
}

However, I get the following error in the console:

Launching lib\main.dart on Android SDK built for x86 in debug mode...
lib\main.dart:1
Parameter format not correct -
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Error: ADB exited with exit code 1
Performing Streamed Install

adb: failed to install C:\Dosyalar\Yazilim\Flutter\Teen Message\teenmessage\build\app\outputs\flutter-apk\app.apk: Failure [INSTALL_FAILED_OLDER_SDK: Failed parse during installPackageLI: /data/app/vmdl61875986.tmp/base.apk (at Binary XML file line #7): Requires newer sdk version #33 (current version is #29)]
Error launching application on Android SDK built for x86.
Exited (sigterm)

How can I solve the problem? Thank you for your help.

Emir Bolat
  • 899
  • 3
  • 14
  • 37

1 Answers1

0

You can see the problem clearly in the error message.

adb: failed to install C:\Dosyalar\Yazilim\Flutter\Teen Message\teenmessage\build\app\outputs\flutter-apk\app.apk: Failure [INSTALL_FAILED_OLDER_SDK: Failed parse during installPackageLI: /data/app/vmdl61875986.tmp/base.apk (at Binary XML file line #7): Requires newer sdk version #33 (current version is #29)]

As you can see above, the error is due to an older SDK version. So, install the required SDK version to get rid of this error.

In order to install New SDK versionstrong text, you can follow the following steps:

  1. Open Android Stdio
  2. Setting > Appearance & Behavior > System Settings > Android SDK
  3. Now click on SDK Platforms
  4. Check the required SDK version = 33
  5. And Click on Apply

Flutter - Requires newer sdk version #33 Error

Ahmad Iqbal Bhatti
  • 707
  • 1
  • 5
  • 8
  • Should only API Level 33 be selected? – Emir Bolat Oct 08 '22 at 15:32
  • Currently Android 11 (R) and Android API 33 are selected and I still get the same error. – Emir Bolat Oct 08 '22 at 15:35
  • Try to update the SDK versions of the project in the build configurations file from android>app>build.gradle . You can see this setting in the section of the default configuration. You can get help from here https://stackoverflow.com/questions/52060516/how-to-change-android-minsdkversion-in-flutter-project I hope it will help you to solve your problem. – Ahmad Iqbal Bhatti Oct 09 '22 at 20:44