Maaz Shahid
Maaz Shahid

Reputation: 103

Errors while accessing camera in Flutter

I'm trying to build an ML app where I want to classify birds and I'm using TensorFlow lite. For taking images as input I'm using the image_picker flutter package. when clicking the take image button I get a bunch of errors. The camera view and file picker does open on an emulator but do not open when the app is exported to a physical device.

My flutter version is 2.2.3 Image_picker version 0.8.4+1 Tflite version 1.1.2

I cannot update any packages to their latest because Tflite is deprecated and is only supported in flutter 2.2.3 max so does the image picker as latest version requires dart 2.14+

Here's the code:

import 'dart:io';
import 'package:image_picker/image_picker.dart';
import 'package:flutter/material.dart';
import 'package:tflite/tflite.dart';

class App extends StatefulWidget {
  const App({Key? key}) : super(key: key);

  @override
  State<App> createState() => _AppState();
}

class _AppState extends State<App> {
  File? _image;
  List? _outputs;
  bool _loading = false;

  @override
  void initState() {
    super.initState();
    _loading = true;

    loadModel().then((value) {
      setState(() {
        _loading = false;
      });
    });
  }

  loadModel() async {
    await Tflite.loadModel(
      model: "assets/model_unquant.tflite",
      labels: "assets/labels.txt",
      numThreads: 1,
    );
  }

  classifyImage(File image) async {
    var output = await Tflite.runModelOnImage(
      path: image.path,
      imageMean: 0.0,
      imageStd: 255.0,
      numResults: 2,
      threshold: 0.2,
      asynch: true,
    );

    setState(() {
      _loading = false;
      _outputs = output;
    });
    print('image sent classify image executed');
    print(Text(_outputs![0]["label"]));
  }

  @override
  void dispose() {
    Tflite.close();
    super.dispose();
  }

  Future getImage({required ImageSource source}) async {
    final image = await ImagePicker().pickImage(source: source);
    if (image == null) return;

    final imageTemporary = File(image.path);

    setState(() {
      this._image = imageTemporary;
      _loading = true;
    });

    classifyImage(_image!);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Bird Classification'),
      ),
      body: SafeArea(
        child: Center(
          child: Column(
            children: [
              SizedBox(
                height: 40,
              ),
              _image == null
                  ? Image.asset('assets/default_bird.png')
                  : Image.file(
                      _image!,
                      width: 0.8 * (MediaQuery.of(context).size.width),
                      height: 0.6 * (MediaQuery.of(context).size.height),
                      fit: BoxFit.fill,
                    ),
              SizedBox(
                height: 20,
              ),
              _image == null
                  ? Container()
                  : _outputs != null
                      ? Text(
                          _outputs![0]["label"],
                          style: TextStyle(color: Colors.black, fontSize: 20),
                        )
                      : Container(child: Text("")),
              SizedBox(
                height: 10,
              ),
              CustomButton(
                title: 'Pick image from gallery',
                icon: Icons.image_outlined,
                onClick: () => getImage(source: ImageSource.gallery),
              ),
              CustomButton(
                title: 'Take picture',
                icon: Icons.camera_alt_outlined,
                onClick: () => getImage(source: ImageSource.camera),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Widget CustomButton({
  required String title,
  required IconData icon,
  required VoidCallback onClick,
}) {
  return Container(
    width: 280,
    child: ElevatedButton(
      onPressed: onClick,
      child: Row(
        children: [
          Icon(icon),
          SizedBox(
            width: 20,
          ),
          Text(title),
        ],
      ),
    ),
  );
}

The error that I'm getting are:

I/ViewRootImpl@ecbfe0f[MainActivity](28932): MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputTransport(28932): Input channel destroyed: 'ClientS', fd=117
I/ViewRootImpl@ecbfe0f[MainActivity](28932): handleAppVisibility mAppVisible=true visible=false
I/SurfaceView@fd299c3(28932): onWindowVisibilityChanged(8) false io.flutter.embedding.android.FlutterSurfaceView{fd299c3 V.E...... ........ 0,0-720,1600} of ViewRootImpl@ecbfe0f[MainActivity]
I/SurfaceView@fd299c3(28932): pST: mTmpTransaction.apply, mTmpTransaction = android.view.SurfaceControl$Transaction@b546c2b
I/SurfaceView@fd299c3(28932): surfaceDestroyed callback.size 1 #2 io.flutter.embedding.android.FlutterSurfaceView{fd299c3 V.E...... ........ 0,0-720,1600}
I/SurfaceView@fd299c3(28932): updateSurface: mVisible = false mSurface.isValid() = true
I/SurfaceView@fd299c3(28932): tryReleaseSurfaces: set mRtReleaseSurfaces = true
I/SurfaceView@fd299c3(28932): 88618700 wPL, frameNr = 0
I/SurfaceView@fd299c3(28932): remove() from RT android.view.SurfaceView$SurfaceViewPositionUpdateListener@54836cc Surface(name=SurfaceView - com.example.classification/com.example.classification.MainActivity@fd299c3@0)/@0xe39ad15
I/SurfaceView@fd299c3(28932): remove() io.flutter.embedding.android.FlutterSurfaceView{fd299c3 V.E...... ........ 0,0-720,1600} Surface(name=SurfaceView - com.example.classification/com.example.classification.MainActivity@fd299c3@0)/@0xe39ad15
I/SurfaceView@fd299c3(28932): aOrMT: uB = true t = android.view.SurfaceControl$Transaction@427f3b8 fN = 0 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionLost:1785 android.graphics.RenderNode$CompositePositionUpdateListener.positionLost:326 
I/SurfaceView@fd299c3(28932): aOrMT: vR.mWNT, vR = ViewRootImpl@ecbfe0f[MainActivity]
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@427f3b8 fN = 0 android.view.SurfaceView.applyOrMergeTransaction:1628 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionLost:1785 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
D/OpenGLRenderer(28932): setSurface called with nullptr
D/OpenGLRenderer(28932): setSurface() destroyed EGLSurface
D/OpenGLRenderer(28932): destroyEglSurface
I/ViewRootImpl@ecbfe0f[MainActivity](28932): Relayout returned: old=(0,0,720,1600) new=(0,0,720,1600) req=(720,1600)8 dur=15 res=0x5 s={false 0} ch=true fn=35
I/SurfaceView@fd299c3(28932): windowStopped(true) false io.flutter.embedding.android.FlutterSurfaceView{fd299c3 V.E...... ........ 0,0-720,1600} of ViewRootImpl@ecbfe0f[MainActivity]
D/SurfaceView@fd299c3(28932): updateSurface: surface is not valid
D/SurfaceView@fd299c3(28932): updateSurface: surface is not valid
I/ViewRootImpl@ecbfe0f[MainActivity](28932): stopped(true) old=false
D/SurfaceView@fd299c3(28932): updateSurface: surface is not valid
I/ViewRootImpl@ecbfe0f[MainActivity](28932): handleAppVisibility mAppVisible=false visible=true
I/SurfaceView@fd299c3(28932): onWindowVisibilityChanged(4) false io.flutter.embedding.android.FlutterSurfaceView{fd299c3 V.E...... ........ 0,0-720,1600} of ViewRootImpl@ecbfe0f[MainActivity]
D/SurfaceView@fd299c3(28932): updateSurface: surface is not valid
D/OpenGLRenderer(28932): setSurface called with nullptr
I/ViewRootImpl@ecbfe0f[MainActivity](28932): Relayout returned: old=(0,0,720,1600) new=(0,0,720,1600) req=(720,1600)4 dur=9 res=0x1 s={false 0} ch=false fn=-1
D/SurfaceView@fd299c3(28932): updateSurface: surface is not valid
D/SurfaceView@fd299c3(28932): updateSurface: surface is not valid
I/ViewRootImpl@ecbfe0f[MainActivity](28932): stopped(false) old=true
I/ViewRootImpl@ecbfe0f[MainActivity](28932): stopped(false) old=false
I/SurfaceView@fd299c3(28932): onWindowVisibilityChanged(0) false io.flutter.embedding.android.FlutterSurfaceView{fd299c3 V.E...... ........ 0,0-720,1600} of ViewRootImpl@ecbfe0f[MainActivity]
D/SurfaceView@fd299c3(28932): updateSurface: surface is not valid
D/OpenGLRenderer(28932): setSurface called with nullptr
I/ViewRootImpl@ecbfe0f[MainActivity](28932): Relayout returned: old=(0,0,720,1600) new=(0,0,720,1600) req=(720,1600)0 dur=16 res=0x7 s={true -5476376608989175808} ch=true fn=-1
D/OpenGLRenderer(28932): eglCreateWindowSurface
I/SurfaceView@fd299c3(28932): windowStopped(false) true io.flutter.embedding.android.FlutterSurfaceView{fd299c3 V.E...... ........ 0,0-720,1600} of ViewRootImpl@ecbfe0f[MainActivity]
I/SurfaceView@fd299c3(28932): pST: sr = Rect(0, 0 - 720, 1600) sw = 720 sh = 1600
I/SurfaceView@fd299c3(28932): onSSPAndSRT: pl = 0 pt = 0 sx = 1.0 sy = 1.0
I/SurfaceView@fd299c3(28932): pST: mTmpTransaction.apply, mTmpTransaction = android.view.SurfaceControl$Transaction@b546c2b
I/SurfaceView@fd299c3(28932): updateSurface: mVisible = true mSurface.isValid() = true
I/SurfaceView@fd299c3(28932): updateSurface: mSurfaceCreated = false surfaceChanged = true visibleChanged = true
I/SurfaceView@fd299c3(28932): surfaceCreated 1 #1 io.flutter.embedding.android.FlutterSurfaceView{fd299c3 V.E...... ........ 0,0-720,1600}
I/SurfaceView@fd299c3(28932): surfaceChanged (720,1600) 1 #1 io.flutter.embedding.android.FlutterSurfaceView{fd299c3 V.E...... ........ 0,0-720,1600}
I/ViewRootImpl@ecbfe0f[MainActivity](28932): [DP] dp(1) 1 android.view.SurfaceView.updateSurface:1375 android.view.SurfaceView.setWindowStopped:383 android.view.SurfaceView.surfaceCreated:2051 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): [DP] pdf(0) 1 android.view.SurfaceView.notifyDrawFinished:599 android.view.SurfaceView.performDrawFinished:586 android.view.SurfaceView.$r8$lambda$st27mCkd9jfJkTrN_P3qIGKX6NY:0 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): [DP] rdf()
D/ViewRootImpl@ecbfe0f[MainActivity](28932): reportDrawFinished (fn: -1) 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): [DP] dp(1) 1 android.view.ViewRootImpl.reportNextDraw:11420 android.view.ViewRootImpl.performTraversals:4193 android.view.ViewRootImpl.doTraversal:2919 
D/ViewRootImpl@ecbfe0f[MainActivity](28932): Creating frameDrawingCallback nextDrawUseBlastSync=false reportNextDraw=true hasBlurUpdates=false
D/ViewRootImpl@ecbfe0f[MainActivity](28932): Creating frameCompleteCallback
I/SurfaceView@fd299c3(28932): uSP: rtp = Rect(0, 0 - 720, 1600) rtsw = 720 rtsh = 1600
I/SurfaceView@fd299c3(28932): onSSPAndSRT: pl = 0 pt = 0 sx = 1.0 sy = 1.0
I/SurfaceView@fd299c3(28932): aOrMT: uB = true t = android.view.SurfaceControl$Transaction@491cd93 fN = 1 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1728 android.graphics.RenderNode$CompositePositionUpdateListener.positionChanged:319 
I/SurfaceView@fd299c3(28932): aOrMT: vR.mWNT, vR = ViewRootImpl@ecbfe0f[MainActivity]
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@491cd93 fN = 1 android.view.SurfaceView.applyOrMergeTransaction:1628 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1728 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
D/ViewRootImpl@ecbfe0f[MainActivity](28932): Received frameDrawingCallback frameNum=1. Creating transactionCompleteCallback=false
D/ViewRootImpl@ecbfe0f[MainActivity](28932): Received frameCompleteCallback  lastAcquiredFrameNum=1 lastAttemptedDrawFrameNum=1
I/ViewRootImpl@ecbfe0f[MainActivity](28932): [DP] pdf(0) 1 android.view.ViewRootImpl.lambda$addFrameCompleteCallbackIfNeeded$3$ViewRootImpl:4995 android.view.ViewRootImpl$$ExternalSyntheticLambda16.run:6 android.os.Handler.handleCallback:938 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): [DP] rdf()
D/ViewRootImpl@ecbfe0f[MainActivity](28932): reportDrawFinished (fn: -1) 
D/InsetsSourceConsumer(28932): ensureControlAlpha: for ITYPE_NAVIGATION_BAR on com.example.classification/com.example.classification.MainActivity
D/MediaScannerConnection(28932): Scanned /data/user/0/com.example.classification/cache/46646d99-774c-426e-be34-f64bdae802cc5773991723760024036.jpg to null
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@659d5c9 fN = 2 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@aceafc fN = 3 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager(28932): startInputInner - Id : 0
I/InputMethodManager(28932): startInputInner - mService.startInputOrWindowGainedFocus
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@4210585 fN = 4 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@b9c0fda fN = 5 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@ae35c0b fN = 6 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@45bbae8 fN = 7 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@5717501 fN = 8 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@2bb4fa6 fN = 9 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@c69ade7 fN = 10 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@3a59d94 fN = 11 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@7ff603d fN = 12 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@33cc032 fN = 13 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@c194183 fN = 14 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@708ff00 fN = 15 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@686c339 fN = 16 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@df2ad7e fN = 17 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@ea472df fN = 18 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@e7f0b2c fN = 19 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: merge t to BBQ
I/.classificatio(28932): Compiler allocated 4564KB to compile void android.view.ViewRootImpl.performTraversals()
D/InsetsSourceConsumer(28932): ensureControlPosition: Point(0, 0) for ITYPE_STATUS_BAR on com.example.classification/com.example.classification.MainActivity from android.view.InsetsSourceConsumer.notifyAnimationFinished:384
I/ViewRootImpl@ecbfe0f[MainActivity](28932): mWNT: t = android.view.SurfaceControl$Transaction@18759f5 fN = 20 android.view.SyncRtSurfaceTransactionApplier.applyTransaction:94 android.view.SyncRtSurfaceTransactionApplier.lambda$scheduleApply$0$SyncRtSurfaceTransactionApplier:71 android.view.SyncRtSurfaceTransactionApplier$$ExternalSyntheticLambda0.onFrameDraw:4 

Upvotes: 1

Views: 2439

Answers (2)

Maaz Shahid
Maaz Shahid

Reputation: 103

I solved the problem by adding permissions for the camera in the AndroidManifest.xml file

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.CAMERA"/>

This solved the issue.

Upvotes: 0

Kaushik Chandru
Kaushik Chandru

Reputation: 17762

Please add this in your manifest

  <uses-feature 
     android:name="android.hardware.camera" 
     android:required="true"/>

For reference

https://github.com/flutter/plugins/blob/main/packages/camera/camera/example/android/app/src/main/AndroidManifest.xml#L22-L24

Upvotes: 2

Related Questions