After successfully a Barcode / Qrcode Scanner on Flutter VSCode, when I try to make apk file, I get an error

824

I built it on a first try. What can you try:

  • Set minSdkVersion to 20
  • run flutter clean
  • upgrade all dependencies
  • run flutter channel stable && flutter upgrade

My configuration:

Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git

Framework • revision c860cba910 (8 days ago) • 2022-03-25 00:23:12 -0500

Engine • revision 57d3bac3dd

Tools • Dart 2.16.2 • DevTools 2.9.2

Share:
824
halfer
Author by

halfer

I'm a (mainly PHP) contract software engineer, with interests in containerisation, testing, automation and culture change. At the time of writing I am on a sabbatical to learn some new things - currently on the radar are Modern JavaScript, Jest and Kubernetes. I wrote a pretty good PHP tutorial, feedback on that is always welcome. I often scribble down software ideas on my blog. My avatar features a sleepy fur bundle that looks after me. I've written about how to ask questions on StackOverflow. I don't spend as much time answering questions these days - I think my time is better spent guiding people how to ask. I try to look after beginners on the platform - if anyone reading this has had a "baptism of fire", don't worry about it - it gets easier. If you'd like to get in touch, find the 'About' page of my blog: there's an email address there.

Updated on December 01, 2022

Comments

  • halfer
    halfer over 1 year

    Code:

    import 'package:flutter/material.dart';
    import 'package:qr_code_scanner/qr_code_scanner.dart';
    import 'dart:io';
    import 'package:flutter/foundation.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      const MyHomePage({Key? key, required this.title}) : super(key: key);
    
    
      final String title;
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
      Barcode? result;
      QRViewController? controller;
    
      // In order to get hot reload to work we need to pause the camera if the platform
      // is android, or resume the camera if the platform is iOS.
      @override
      void reassemble() {
        super.reassemble();
        if (Platform.isAndroid) {
          controller!.pauseCamera();
        } else if (Platform.isIOS) {
          controller!.resumeCamera();
        }
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Column(
            children: <Widget>[
              Expanded(
                flex: 5,
                child: QRView(
                  key: qrKey,
                  onQRViewCreated: _onQRViewCreated,
                ),
              ),
              Expanded(
                flex: 1,
                child: Center(
                  child: (result != null)
                      ? Text(
                      'Barcode Type: ${describeEnum(result!.format)}   Data: ${result!.code}')
                      : Text('Scan a code'),
                ),
              )
            ],
          ),
        );
      }
    
      void _onQRViewCreated(QRViewController controller) {
        this.controller = controller;
        controller.scannedDataStream.listen((scanData) {
          setState(() {
            result = scanData;
          });
        });
      }
    
      @override
      void dispose() {
        controller?.dispose();
        super.dispose();
      }
    }
    

    Error:

    flutter build apk --build-name=1.0.4 --build-number=4
    
     Building with sound null safety 
    
    e: D:\flutter\.pub-cache\hosted\pub.dartlang.org\qr_code_scanner-0.7.0\android\src\main\kotlin\net\touchcapture\qr\flutterqr\QRView.kt: (23, 1): Class 'QRView' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
    e: D:\flutter\.pub-cache\hosted\pub.dartlang.org\qr_code_scanner-0.7.0\android\src\main\kotlin\net\touchcapture\qr\flutterqr\QRView.kt: (216, 26): Null can not be a value of a non-null type String
    e: D:\flutter\.pub-cache\hosted\pub.dartlang.org\qr_code_scanner-0.7.0\android\src\main\kotlin\net\touchcapture\qr\flutterqr\QRView.kt: (247, 26): Null can not be a value of a non-null type String
    e: D:\flutter\.pub-cache\hosted\pub.dartlang.org\qr_code_scanner-0.7.0\android\src\main\kotlin\net\touchcapture\qr\flutterqr\QRView.kt: (310, 5): 'onRequestPermissionsResult' overrides nothing
    e: D:\flutter\.pub-cache\hosted\pub.dartlang.org\qr_code_scanner-0.7.0\android\src\main\kotlin\net\touchcapture\qr\flutterqr\QRViewFactory.kt: (10, 1): Class 'QRViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory
    e: D:\flutter\.pub-cache\hosted\pub.dartlang.org\qr_code_scanner-0.7.0\android\src\main\kotlin\net\touchcapture\qr\flutterqr\QRViewFactory.kt: (13, 5): 'create' overrides nothing
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':qr_code_scanner:compileReleaseKotlin'.
    > Compilation error. See log for more details
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 3m 59s
    Running Gradle task 'assembleRelease'...                          242.3s
    Gradle task assembleRelease failed with exit code 1