shaqian / flutter_tflite

Flutter plugin for TensorFlow Lite
https://pub.dartlang.org/packages/tflite
MIT License
630 stars 404 forks source link

The plugin `tflite` uses a deprecated version of the Android embedding. #239

Open siddhant-debug opened 2 years ago

siddhant-debug commented 2 years ago

The plugin tflite uses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs. If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

rkohari commented 2 years ago

am also getting this same issue when i try to run the project ,its showing exaclty the same issue

rkohari commented 2 years ago

this is my log [✓] Flutter (Channel stable, 2.5.3, on macOS 12.1 21C52 darwin-arm, locale en-IN) • Flutter version 2.5.3 at /Applications/UserInstalled/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 18116933e7 (3 months ago), 2021-10-15 10:46:35 -0700 • Engine revision d3ea636dc5 • Dart version 2.14.4

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/hari/Library/Android/sdk ✗ cmdline-tools component is missing Run path/to/sdkmanager --install "cmdline-tools;latest" See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run flutter doctor --android-licenses to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 13.2.1, Build version 13C100 • CocoaPods version 1.11.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[☠] IntelliJ IDEA Ultimate Edition (the doctor check crashed) ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues. ✗ FormatException: Unexpected extension byte (at offset 5) • #0 _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1788:7)

1 Utf8Decoder.convert (dart:convert/utf.dart:318:42)

  #2      InputStream.readString (package:archive/src/util/input_stream.dart:199:30)
  #3      new ZipDirectory.read (package:archive/src/zip/zip_directory.dart:40:30)
  #4      ZipDecoder.decodeBuffer (package:archive/src/zip_decoder.dart:19:30)
  #5      ZipDecoder.decodeBytes (package:archive/src/zip_decoder.dart:14:12)
  #6      IntelliJPlugins._findPluginXml (package:flutter_tools/src/intellij/intellij.dart:130:44)
  #7      IntelliJPlugins._readPackageVersion (package:flutter_tools/src/intellij/intellij.dart:141:40)
  #8      IntelliJPlugins.validatePackage (package:flutter_tools/src/intellij/intellij.dart:63:35)
  #9      IntelliJValidator.validate (package:flutter_tools/src/intellij/intellij_validator.dart:103:15)
  #10     asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32)
  #11     asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:109:18)
  #12     _rootRun (dart:async/zone.dart:1428:13)
  #13     _CustomZone.run (dart:async/zone.dart:1328:19)
  #14     _runZoned (dart:async/zone.dart:1863:10)
  #15     runZonedGuarded (dart:async/zone.dart:1851:12)
  #16     runZoned (dart:async/zone.dart:1782:12)
  #17     asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
  #18     Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:200:9)
  #19     Doctor.diagnose (package:flutter_tools/src/doctor.dart:304:47)
  #20     DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:50:47)
  #21     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1274:12)
  <asynchronous suspension>
  #22     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1125:27)
  <asynchronous suspension>
  #23     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
  <asynchronous suspension>
  #24     CommandRunner.runCommand (package:args/command_runner.dart:209:13)
  <asynchronous suspension>
  #25     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
  <asynchronous suspension>
  #26     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
  <asynchronous suspension>
  #27     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
  <asynchronous suspension>
  #28     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
  <asynchronous suspension>
  #29     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
  <asynchronous suspension>
  #30     main (package:flutter_tools/executable.dart:92:3)
  <asynchronous suspension>

[✓] VS Code (version 1.62.3) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available) • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 31) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.71

rkohari commented 2 years ago

@siddhant-debug did u find any solution for this issue?

siddhant-debug commented 2 years ago

@siddhant-debug did u find any solution for this issue?

No

rkohari commented 2 years ago

@siddhant-debug i fixed this issue,open andriod folder separatly,after it will download some necessary tflite files,it took around 5 mins i think.after close tha project and clear flutter ,now it will run .

TjayAmit commented 2 years ago

@siddhant-debug so the only solution is to wait for a new version that support Android V2?

siddhant-debug commented 2 years ago

@rkohari can u explain ?

dasrocky commented 2 years ago

@rkohari can u explain ?

@siddhant-debug Check this user's repo @rkohari "imagecapture" might help u. while writing this comment I still didn't try it myself, although am facing the same issue.

dasrocky commented 2 years ago

@siddhant-debug so the only solution is to wait for a new version that support Android V2?

I found a solution from flutter team migration doc(my comment from reddit). After fixing the the migration issue, i even added a pull request Object_detection_flutter repo. Hope this helped.

AjilAshok commented 2 years ago

any one find the solution?

dasrocky commented 2 years ago

any one find the solution?

I posted a solution for android embedding issue in Object_detection_flutter repo, which is an example of tflite_flutter package. The thing is, devs of tflite and tflite_flutter repo are not active (correct me if I am wrong). TBH it is a very simple solution just that u have to spend some time in reading the docs provided by flutter team for migration of android embedding. Either u can check the pull request file changes made and do the same or check the comment this on reddit.

Edit: Pull request, mentioned above in my message, doesn't work any more.

Daniek3d commented 2 years ago

Is it possible to apply this change in the main branch to generate a new version? Or is the project already advanced?

Abel-Saji-George commented 2 years ago

any one find the solution?

I posted a solution for android embedding issue in Object_detection_flutter repo, which is an example of tflite_flutter package. The thing is, devs of tflite and tflite_flutter repo are not active (correct me if I am wrong). TBH it is a very simple solution just that u have to spend some time in reading the docs provided by flutter team for migration of android embedding. Either u can check the pull request file changes made and do the same or check the comment this on reddit.

i can't seem to find the file mentioned in the video for the java part instead i have a GeneratedPluginRestraint page in the java folder what should i do. Is there some other guidelines to follow for the same ? pls respond asap 🙇i have to turn in my project this weekend

Abel-Saji-George commented 2 years ago

any one find the solution?

I posted a solution for android embedding issue in Object_detection_flutter repo, which is an example of tflite_flutter package. The thing is, devs of tflite and tflite_flutter repo are not active (correct me if I am wrong). TBH it is a very simple solution just that u have to spend some time in reading the docs provided by flutter team for migration of android embedding. Either u can check the pull request file changes made and do the same or check the comment this on reddit.

bro it's urgent pls i need ur help 🙇🙇🙇I'll even send over a quick 500 for fixing this issue on my project .I'm a student and im having my lab exam this week and kind of in an extremely shitty situation now

dasrocky commented 2 years ago

Apologies for late reply, weirdly didnt receive any mail for above replies, checking mail found ur reply way down in mail. Thank you for offering, but I don't need one. I am happy to help but note that I am not that knowledgable in dart and flutter, I happen to refer documentation & some video that did the work for me. Also note that I worked on fixing android embedding v2 migration of tflite by amishgarg.tech (tflite_flutter). Again am happy to help.

Abel-Saji-George commented 2 years ago

thank you bro for getting back to me I'll contact you today itself via discord.I desperately need your help on this matter at hand🙇My teacher was kind enough to give me a couple of days more time for solving the issue

On Thu, Jul 21, 2022 at 12:41 PM Rocky @.***> wrote:

Apologies for late reply, weirdly didnt receive any mail for above msg, checking mail found ur issue post way down in mail. Thank you for offering, but I don't need one. I am happy to help but note that I am not that knowledgable in dart and flutter, I happen to refer documentation & some video that did the work for me. Also note that I worked on fixing android embedding v2 migration of tflite by amishgarg.tech (tflite_flutter https://pub.dev/packages/tflite_flutter). Again am happy to help. Discord Id -> EliteArmedForce#2225

— Reply to this email directly, view it on GitHub https://github.com/shaqian/flutter_tflite/issues/239#issuecomment-1191126739, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP2Y4EMAJLNEXC6QMOA5D33VVDZ2RANCNFSM5MCXA6GQ . You are receiving this because you commented.Message ID: @.***>

saadsb20 commented 2 years ago

I faced the same issue, I just followed the migration steps here and the project runs directly.

francisrod01 commented 2 years ago

I faced the same issue, I just followed the migration steps here and the project runs directly.

@shaqian I think it could help migrate flutter_tflite Android embedding.

orbitsdev commented 1 year ago

any one find the solution?

I posted a solution for android embedding issue in Object_detection_flutter repo, which is an example of tflite_flutter package. The thing is, devs of tflite and tflite_flutter repo are not active (correct me if I am wrong). TBH it is a very simple solution just that u have to spend some time in reading the docs provided by flutter team for migration of android embedding. Either u can check the pull request file changes made and do the same or check the comment this on reddit.

Edit: Pull request, mentioned above in my message, doesn't work any more.

sir can you do video tutorial about this sir

StephanieOgu commented 1 year ago

the only thing which worked for me is not to use tflite dependency. Please try [tflite_flutter]

fransay commented 1 year ago

@shaqian, you've got a great plugin however the Android embeddings migration is continuously making it unreliable to use. Kindly take a few hours of your busy schedule and do this migration. I think it is not that difficult if you follow the official documentation from flutter: https://docs.flutter.dev/release/breaking-changes/plugin-api-migration https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

dasrocky commented 1 year ago

@fransay & everyone u dont have to worry about this package problems, as this flutter package is officially supported by TensorFlow themselves. Here is the repo: flutter_tflite

Edit: My bad, correction the tensorflow officially supports Amish Garg's tflite_flutter_plugin

francisrod01 commented 1 year ago

@fransay & everyone u dont have to worry about this package problems, as this flutter package is officially supported by TensorFlow themselves. Here is the repo: flutter_tflite

Edit: My bad, correction the tensorflow officially supports Amish Garg's tflite_flutter_plugin

@dasrocky I invite you and more folks to help me implement more use cases for Tensorflow official plugin.

I didn't receive a warm welcome when I asked them for some use cases. https://github.com/tensorflow/flutter-tflite/issues/105#issuecomment-1634816362

fransay commented 1 year ago

@francisrod01, Sure!, sounds good. Let me know when you are start. I'd love to contribute.

francisrod01 commented 1 year ago

@francisrod01, Sure!, sounds good. Let me know when you are start. I'd love to contribute.

I just opened a Discussion in the TensorFlow official support repo. https://github.com/tensorflow/flutter-tflite/discussions/116