Skip to content

🐛 [firebase_ml_vision] PlatformException (error 13) Barcode engine is nil #5043

@svprdga

Description

@svprdga

Bug report

Describe the bug
The barcode scanner is broken in iOS.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a flutter app to scan barcodes with the versions specified in the attached log.
  2. Open the app and try to scan a barcode.

Expected behavior

The barcode is successfully scanned.


Additional context

  • There are other issues regarding this topic, none of the solutions posted fixes the issue for me.
  • I have added pod 'Firebase/MLVisionBarcodeModel' to the Podfile as the documentation says and as other as said.
  • I cannot run the project because of a pod issue, see attached logs for detail.

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.1 20D74 darwin-x64, locale es-ES)
    • Flutter version 1.22.6 at /Users/svprdga/opt/flutter
    • Framework revision 9b2d32b605 (3 weeks ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5


[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/svprdga/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0

[✓] Connected device (2 available)
    • SM N975F (mobile)        • RF8N10PV53N               • android-arm64 • Android 11 (API 30)
    • iPhone de David (mobile) • 00008030-00065D012E47802E • ios           • iOS 14.3

! Doctor found issues in 1 category.

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 2.10.5
Flutter SDK 1.22.6
super_qr_code_reader_flutter 1.5.0+7

dependencies:
- app_settings 4.0.4 [flutter]
- camera 0.7.0+1 [flutter camera_platform_interface pedantic quiver]
- common_lib 2.0.0+5 [flutter cupertino_icons intl package_info url_launcher store_redirect flutter_platform_widgets webview_flutter]
- cupertino_icons 1.0.0
- device_info 1.0.0 [flutter device_info_platform_interface]
- firebase_analytics 7.0.1 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface]
- firebase_core 0.7.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_crashlytics 0.4.0+1 [flutter stack_trace firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface]
- firebase_ml_vision 0.10.0 [flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math]
- flutter_platform_widgets 0.72.0 [flutter]
- intl 0.16.1 [path]
- logger 0.9.4
- path 1.8.0-nullsafety.1
- permission_handler 5.0.1+1 [flutter meta permission_handler_platform_interface]
- provider 4.3.3 [collection flutter nested]
- qr_flutter 3.2.0 [flutter qr]
- sqflite 1.3.2+2 [flutter sqflite_common path]
- url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- uuid 2.2.2 [crypto convert]
- validators 2.0.1 [vin_decoder]

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- async 2.5.0-nullsafety.1 [collection]
- basic_utils 2.7.0 [http logging json_annotation pointycastle convert crypto]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- camera_platform_interface 1.5.0 [flutter meta plugin_platform_interface cross_file stream_transform]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- clock 1.1.0-nullsafety.1
- collection 1.15.0-nullsafety.3
- convert 2.1.1 [charcode typed_data]
- cross_file 0.1.0 [flutter http meta]
- crypto 2.1.5 [collection convert typed_data]
- device_info_platform_interface 1.0.1 [flutter meta plugin_platform_interface]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- firebase 7.3.3 [http http_parser js]
- firebase_analytics_platform_interface 1.0.3 [flutter meta]
- firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta]
- firebase_core_platform_interface 3.0.1 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.1+3 [firebase_core_platform_interface flutter flutter_web_plugins meta js]
- firebase_crashlytics_platform_interface 1.1.6 [flutter meta collection firebase_core plugin_platform_interface]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- js 0.6.2
- json_annotation 3.1.1
- logging 0.11.4
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- nested 0.0.4 [flutter]
- package_info 0.4.3+2 [flutter]
- pedantic 1.9.2 [meta]
- permission_handler_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- plugin_platform_interface 1.0.3 [meta]
- pointycastle 2.0.1
- qr 1.3.0 [meta]
- quiver 2.1.5 [matcher meta]
- random_string 2.1.0
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- sqflite_common 1.0.3+1 [synchronized path meta]
- stack_trace 1.10.0-nullsafety.1 [path]
- store_redirect 1.0.2 [flutter]
- stream_channel 2.1.0-nullsafety.1 [async]
- stream_transform 1.2.0
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- synchronized 2.2.0+2
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.3 [collection]
- url_launcher_linux 0.0.1+4 [flutter]
- url_launcher_macos 0.0.1+9 [flutter]
- url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.5+1 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+3 [flutter]
- vector_math 2.1.0-nullsafety.3
- vin_decoder 0.1.3 [meta basic_utils http random_string]
- webview_flutter 1.0.7 [flutter]

Podfile

Content of the Podfile

Click To Expand
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  pod 'Firebase/MLVisionBarcodeModel'
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|

          # You can remove unused permissions here
          # for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/develop/permission_handler/ios/Classes/PermissionHandlerEnums.h
          # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
            '$(inherited)',

            ## dart: PermissionGroup.calendar
            'PERMISSION_EVENTS=0',

            ## dart: PermissionGroup.reminders
            'PERMISSION_REMINDERS=0',

            ## dart: PermissionGroup.contacts
            'PERMISSION_CONTACTS=0',

            ## dart: PermissionGroup.camera
            # 'PERMISSION_CAMERA=0',

            ## dart: PermissionGroup.microphone
            'PERMISSION_MICROPHONE=0',

            ## dart: PermissionGroup.speech
            'PERMISSION_SPEECH_RECOGNIZER=0',

            ## dart: PermissionGroup.photos
            'PERMISSION_PHOTOS=0',

            ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
            'PERMISSION_LOCATION=0',

            ## dart: PermissionGroup.notification
            'PERMISSION_NOTIFICATIONS=0',

            ## dart: PermissionGroup.mediaLibrary
            'PERMISSION_MEDIA_LIBRARY=0',

            ## dart: PermissionGroup.sensors
            'PERMISSION_SENSORS=0'
          ]

        end
  end
end

Pod install

Result of executing pod install in the iOS folder. I have also tried other commands (pod update an other suggested by CocoaPods) without success.

Click to Expand
Analyzing dependencies
firebase_analytics: Using Firebase SDK version '7.3.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '7.3.0' defined in 'firebase_core'
firebase_crashlytics: Using Firebase SDK version '7.3.0' defined in 'firebase_core'
firebase_ml_vision: Using Firebase SDK version '7.3.0' defined in 'firebase_core'
[!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
  In snapshot (Podfile.lock):
    Firebase/CoreOnly (= 7.3.0)

  In Podfile:
    Firebase/MLVisionBarcodeModel was resolved to 5.0.0, which depends on
      Firebase/CoreOnly (= 5.0.0)

    firebase_core (from `.symlinks/plugins/firebase_core/ios`) was resolved to 0.7.0, which depends on
      Firebase/CoreOnly (= 7.3.0)


You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `Firebase/CoreOnly` inside your development pod `firebase_core`.
   You should run `pod update Firebase/CoreOnly` to apply changes you've made.


Error shown if Firebase/MLVisionBarcodeModel is NOT in Podfile

Click to Expand
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0   _ScannerFragmentState._processFrame (package:super_qr_code_reader_flutter/presentation/scanner/scanner_fragment.dart:288:12)
flutter: │ #1   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ ⛔ Error processing camera frame: PlatformException(Error 13, com.firebase.ml, Barcode engine is nil., null)
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs AttentionThis issue needs maintainer attention.type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions