title: Failed to run model, -67108857, java.lang.NegativeArrayS izeException: -67108857
body: <p>Has anyone solved this problem while using tflite package in flutter every model i used i get that issue of arrays?<br>
  Unhandled Exception: PlatformException(Failed to run model, -67108857, java.lang.NegativeArrayS
  izeException: -67108857<br>
  How can i solve it.</p>
  <p>Here is the basic code i was trying to run but landed into an error.
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import 'dart:io';
  import 'package:flutter/material.dart';
  import 'package:flutter/services.dart';
  import 'package:tflite/tflite.dart';
  import 'package:image_picker/image_picker.dart';
  
  import 'home.dart';
  //import 'package:image/image.dart' as img;
  
  void main() =&gt; runApp(MyApp());
  
  const String ssd = "SSD MobileNet";
  const String yolo = "Tiny YOLOv2";
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Object Detection App',
        home: StaticImage(),
      );
    }
  }
  
  class StaticImage extends StatefulWidget {
  
    @override
    _StaticImageState createState() =&gt; _StaticImageState();
  }
  
  class _StaticImageState extends State&lt;StaticImage&gt; {
    File _image;
    List _recognitions;
    bool _busy;
    double _imageWidth, _imageHeight;
  
    final picker = ImagePicker();
  
    // this function loads the model
    loadTfModel() async {
      await Tflite.loadModel(
        model: "assets/tflite/model_unquant.tflite",
        labels: "assets/tflite/label.txt",
      );
    }
  
    // this function detects the objects on the image
    detectObject(File image) async {
      var recognitions = await Tflite.detectObjectOnImage(
        path: image.path,       // required
        model: "SSDMobileNet",
        imageMean: 127.5,     
        imageStd: 127.5,      
        threshold: 0.4,       // defaults to 0.1
        numResultsPerClass: 10,// defaults to 5
        asynch: true          // defaults to true
      );
      FileImage(image)
          .resolve(ImageConfiguration())
          .addListener((ImageStreamListener((ImageInfo info, bool _) {
            setState(() {
              _imageWidth = info.image.width.toDouble();
              _imageHeight = info.image.height.toDouble();
            });
          }))); 
      setState(() {
        _recognitions = recognitions;
      });
    }
  
    @override
    void initState() { 
      super.initState();
      _busy = true;
      loadTfModel().then((val) {{
        setState(() {
          _busy = false;
        });
      }});
    }
    // display the bounding boxes over the detected objects
    List&lt;Widget&gt; renderBoxes(Size screen) {
      if (_recognitions == null) return [];
      if (_imageWidth == null || _imageHeight == null) return [];
  
      double factorX = screen.width;
      double factorY = _imageHeight / _imageHeight * screen.width;
  
      Color blue = Colors.blue;
  
      return _recognitions.map((re) {
        return Container(
          child: Positioned(
            left: re["rect"]["x"] * factorX,
            top: re["rect"]["y"] * factorY,
            width: re["rect"]["w"] * factorX,
            height: re["rect"]["h"] * factorY,
            child: ((re["confidenceInClass"] &gt; 0.50))? Container(
                decoration: BoxDecoration(
                  border: Border.all(
                  color: blue,
                  width: 3,
                )
              ),
              child: Text(
                "${re["detectedClass"]} ${(re["confidenceInClass"] * 100).toStringAsFixed(0)}%",
                style: TextStyle(
                  background: Paint()..color = blue,
                  color: Colors.white,
                  fontSize: 15,
                ),
              ),
            ) : Container()
          ),
        );
      }).toList();
    }
  
    @override
    Widget build(BuildContext context) {
      Size size = MediaQuery.of(context).size;
  
      List&lt;Widget&gt; stackChildren = [];
  
      stackChildren.add(
        Positioned(
          // using ternary operator
          child: _image == null ? 
          Container(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: &lt;Widget&gt;[
                Text("Please Select an Image"),
              ],
            ),
          )
        : // if not null then 
          Container(
            child:Image.file(_image)
          ),
        )
      );
  
      stackChildren.addAll(renderBoxes(size));
  
      if (_busy) {
        stackChildren.add(
          Center(
            child: CircularProgressIndicator(),
          )
        );
      }
  
      return Scaffold(
        appBar: AppBar(
          title: Text("Object Detector"),
        ),
        floatingActionButton: Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: &lt;Widget&gt;[
            FloatingActionButton(
              heroTag: "Fltbtn2",
              child: Icon(Icons.camera_alt),
              onPressed: getImageFromCamera,
            ),
            SizedBox(width: 10,),
            FloatingActionButton(
              heroTag: "Fltbtn1",
              child: Icon(Icons.photo),
              onPressed: getImageFromGallery,
            ),
          ],
        ),
        body: Container(
          alignment: Alignment.center,
          child:Stack(
          children: stackChildren,
        ),
        ),
      );
    }
    // gets image from camera and runs detectObject
    Future getImageFromCamera() async {
      final pickedFile = await picker.getImage(source: ImageSource.camera);
  
      setState(() {
        if(pickedFile != null) {
          _image = File(pickedFile.path);
        } else {
          print("No image Selected"); 
        }
      });
      detectObject(_image);
    }
    // gets image from gallery and runs detectObject
    Future getImageFromGallery() async {
      final pickedFile = await picker.getImage(source: ImageSource.gallery);
      setState(() {
        if(pickedFile != null) {
          _image = File(pickedFile.path);
        } else {
          print("No image Selected");
        }
      });
      detectObject(_image);
    }
  }</code></pre>
  </div>
  </div>
  
  This is the code i was trying to run
  <a href="https://i.stack.imgur.com/aPOrK.png" rel="nofollow noreferrer">Image for error is here</a></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>name: ml_classifier
  description: A new Flutter project.
  
  # The following line prevents the package from being accidentally published to
  # pub.dev using `pub publish`. This is preferred for private packages.
  publish_to: 'none' # Remove this line if you wish to publish to pub.dev
  
  # The following defines the version and build number for your application.
  # A version number is three numbers separated by dots, like 1.2.43
  # followed by an optional build number separated by a +.
  # Both the version and the builder number may be overridden in flutter
  # build by specifying --build-name and --build-number, respectively.
  # In Android, build-name is used as versionName while build-number used as versionCode.
  # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
  # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
  # Read more about iOS versioning at
  # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
  version: 1.0.0+1
  
  environment:
    sdk: "&gt;=2.7.0 &lt;3.0.0"
  
  dependencies:
    flutter:
      sdk: flutter
    tflite: ^1.0.4
    image_picker: ^0.6.1+8
    image: ^2.1.4
  
    # The following adds the Cupertino Icons font to your application.
    # Use with the CupertinoIcons class for iOS style icons.
    cupertino_icons: ^0.1.2
  
  dev_dependencies:
    flutter_test:
      sdk: flutter
  
  # The following section is specific to Flutter.
  flutter:
    # To add assets to your application, add an assets section, like this:
    assets:
      - assets/tflite/model_unquant.tflite
      - assets/tflite/label.txt
   </code></pre>
  </div>
  </div>
  </p>