Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mlkit_scanner package conflicts with google_mlkit_text_recognition package #16

Open
panksi opened this issue Oct 3, 2022 · 2 comments

Comments

@panksi
Copy link

panksi commented Oct 3, 2022

Hi all,
thanks for the efforts in making this package.
I started working on the app which uses this scanner a month ago. this package was one of the first that I initialized and tested as a widget to make sure I can use it when I need it. I used the example you pointed out and Initialized the BarcodeScanner Widget accordingly. However, now when I got back to it to actually use it (or let's say join with the rest of the screens in the app) It just keeps crashing. First I taught it's the "clash" between google_ml_kit and mlkit_scanner packages, but now, as I ended up trying to init the page with mlkit_scanner directly as a child class of MyApp (main) widget:

In my main.dart file I did this

class MyApp extends StatelessWidget {
  const MyApp(
      {
      Key? key})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'testapp',
      theme: theme,
      home: const ScanQRCodePage(),
    );
  }
}

in scan QR code page I did this:

import 'package:flutter/material.dart';
import '../ui/helpers/animations_helper.dart';
import 'package:mlkit_scanner/mlkit_scanner.dart';
import './connect_bluetooth_page.dart';

class ScanQRCodePage extends StatefulWidget {

  const ScanQRCodePage({super.key});

  @override
  State<ScanQRCodePage> createState() => ScanQRCodePageState();
}

class ScanQRCodePageState extends State<ScanQRCodePage> {
  BarcodeScannerController? barcodeScannerController;
  String _imei = '';

  @override
  Widget build(BuildContext context) => Scaffold(
      appBar: AppBar(title: const Text('Scan QR Code')),
      body: Column(
        children: [
          Container(
            padding: const EdgeInsets.all(24),
            child: Text('scan QR code page $_imei'),
          ),

          Expanded(
            flex: 10,
            child: BarcodeScanner(
                cropOverlay: const CropRect(scaleHeight: 0.2, scaleWidth: 0.3),
                onScannerInitialized: (cntr) => _onScannerInitialized(cntr),
                onScan: (code) {

                  if (code.length == 15) {
                    setState(() {
                      _imei = code;
                    });

                    barcodeScannerController?.cancelScan();

                    Navigator.push(
                      context,
                      CustomPageRoute(
                          builder: ConnectBluetoothPage(imei: _imei),
                          direction: AxisDirection.right),
                    );
                  }
                },
                onCameraInitializeError: (error) {
                  print('ERROR ON CAMERA ' + error.toString());
                }),
          )
        ],
      ));

  Future<void> _onScannerInitialized(
      BarcodeScannerController? controller) async {
    if (controller == null) {
      print('Controller is null, terminating');
      return;
    }
    setState(() {
       barcodeScannerController = controller;
    });
    await barcodeScannerController.startScan(100);
  }
}

This is the Debug log:

D/FlutterBluePlugin(30710): onAttachedToEngine
D/FlutterBluePlugin(30710): setup
D/FlutterBluePlugin(30710): onAttachedToActivity
Connecting to VM Service at ws://127.0.0.1:58232/iO3McQOZTTo=/ws
D/ForceDarkHelper(30710): updateByCheckExcludeList: pkg: com.example.fleetstep_connect_testapp activity: com.example.fleetstep_connect_testapp.MainActivity@14699b1
I/chatty  (30710): uid=10326(com.example.fleetstep_connect_testapp) identical 3 lines
D/ForceDarkHelper(30710): updateByCheckExcludeList: pkg: com.example.fleetstep_connect_testapp activity: com.example.fleetstep_connect_testapp.MainActivity@14699b1
W/Gralloc3(30710): mapper 3.x is not supported
D/ForceDarkHelper(30710): updateByCheckExcludeList: pkg: com.example.fleetstep_connect_testapp activity: com.example.fleetstep_connect_testapp.MainActivity@14699b1
W/Gralloc3(30710): allocator 3.x is not supported
E/libc    (30710): Access denied finding property "vendor.camera.hal1.packagelist"
W/CameraViewEngin(30710): type=1400 audit(0.0:8051): avc: denied { read } for name="u:object_r:vendor_default_prop:s0" dev="tmpfs" ino=25852 scontext=u:r:untrusted_app:s0:c70,c257,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
I/connect_testap(30710): ProcessProfilingInfo new_methods=1619 is saved saved_to_disk=1 resolve_classes_delay=8000
D/ForceDarkHelper(30710): updateByCheckExcludeList: pkg: com.example.fleetstep_connect_testapp activity: com.example.fleetstep_connect_testapp.MainActivity@14699b1
I/chatty  (30710): uid=10326(com.example.fleetstep_connect_testapp) identical 3 lines
D/ForceDarkHelper(30710): updateByCheckExcludeList: pkg: com.example.fleetstep_connect_testapp activity: com.example.fleetstep_connect_testapp.MainActivity@14699b1
I/Process (30710): Sending signal. PID: 30710 SIG: 9

UPDATE: As I wanted to make sure that the issue truly exists I just copy-pasted the example to my project in order to see if it works. When I hit the startScan button the app just crashes. the only thing in debug log is this:
I/Process (12983): Sending signal. PID: 12983 SIG: 9
Lost connection to device.
Exited (sigterm)

UPDATE 2: I created a completely new project with mlkit_scanner and it worked. Got back to my project and commented out google_mlkit_text_recognition package and now it worked in my project also. This basically means: mlkit_scanner conflicts with google_mlkit_text_recognition. This is as far as I go, hope you find out what's the issue here. good luck.

@panksi panksi changed the title I guess the issue is "Access denied finding property "vendor.camera.hal1.packagelist"".... mlkit_scanner package conflicts with google_mlkit_text_recognition package Oct 4, 2022
@daga-hiwot
Copy link

@panksi have you get a solution?

@panksi
Copy link
Author

panksi commented Jan 13, 2023

@panksi have you get a solution?

I just switched to google_mlkit_scanner package which is a part of google_mlkit bundle and it worked well with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants