Skip to content

Add-to-app on iOS: crash of PathProvider (PlatformException) #552

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

Closed
kundankuldeep opened this issue Aug 17, 2023 · 4 comments
Closed

Add-to-app on iOS: crash of PathProvider (PlatformException) #552

kundankuldeep opened this issue Aug 17, 2023 · 4 comments
Labels
more info required Needs more info to become actionable. Auto-closed if no response. question How to do something/general question

Comments

@kundankuldeep
Copy link

kundankuldeep commented Aug 17, 2023

Overview: Building a framework with flutter to integrate in existing native IOS Application. The framework consisting of Objectbox for some data persistence, which is not getting initialised when run as framework, giving out channel-error

Basic info:

  • ObjectBox version: ^2.2.0
  • ObjectBox flutter libs: ^2.2.0
  • path_provider: ^2.1.0
  • Flutter/Dart SDK: Flutter 3.13.0 , Tools • Dart 3.1.0 • DevTools 2.25.0
  • Reproducible: occurring every time
  • Build OS: macOs 13.4.1 (c)
  • Deployment device or OS: iOS 16.6
  • output of - pub deps --no-dev
    Dart SDK 3.1.0
    Flutter SDK 3.13.0
    flutter_lib 1.0.0+1
    ├── another_flushbar 1.12.30
    │ └── flutter...
    ├── cupertino_icons 1.0.5
    ├── dio 4.0.6
    │ ├── http_parser 4.0.2
    │ │ ├── source_span 1.10.0
    │ │ │ ├── term_glyph 1.2.1
    │ │ │ ├── collection...
    │ │ │ └── path...
    │ │ ├── string_scanner 1.2.0
    │ │ │ └── source_span...
    │ │ ├── typed_data 1.3.2
    │ │ │ └── collection...
    │ │ └── collection...
    │ └── path...
    ├── flutter 0.0.0
    │ ├── characters 1.3.0
    │ ├── collection 1.17.2
    │ ├── material_color_utilities 0.5.0
    │ │ └── collection...
    │ ├── meta 1.9.1
    │ ├── sky_engine 0.0.99
    │ ├── vector_math 2.1.4
    │ └── web 0.1.4-beta
    ├── flutter_inappwebview 5.7.2+3
    │ └── flutter...
    ├── flutter_overlay_loader 2.0.0
    │ └── flutter...
    ├── flutter_svg 1.1.6
    │ ├── path_drawing 1.0.1
    │ │ ├── path_parsing 1.0.1
    │ │ │ ├── meta...
    │ │ │ └── vector_math...
    │ │ ├── flutter...
    │ │ ├── meta...
    │ │ └── vector_math...
    │ ├── xml 6.3.0
    │ │ ├── petitparser 5.4.0
    │ │ │ └── meta...
    │ │ ├── collection...
    │ │ └── meta...
    │ ├── flutter...
    │ ├── meta...
    │ └── vector_math...
    ├── internet_connection_checker 1.0.0+1
    ├── json_annotation 4.8.1
    │ └── meta...
    ├── numberpicker 2.1.2
    │ ├── infinite_listview 1.1.0
    │ │ └── flutter...
    │ └── flutter...
    ├── objectbox 2.2.0
    │ ├── ffi 2.1.0
    │ ├── flat_buffers 2.0.5
    │ ├── collection...
    │ ├── meta...
    │ └── path...
    ├── objectbox_flutter_libs 2.2.0
    │ ├── flutter...
    │ ├── objectbox...
    │ └── path_provider...
    ├── path 1.8.3
    ├── path_provider 2.1.0
    │ ├── path_provider_android 2.1.0
    │ │ ├── flutter...
    │ │ └── path_provider_platform_interface...
    │ ├── path_provider_foundation 2.3.0
    │ │ ├── flutter...
    │ │ └── path_provider_platform_interface...
    │ ├── path_provider_linux 2.2.0
    │ │ ├── xdg_directories 1.0.2
    │ │ │ ├── meta...
    │ │ │ └── path...
    │ │ ├── ffi...
    │ │ ├── flutter...
    │ │ ├── path...
    │ │ └── path_provider_platform_interface...
    │ ├── path_provider_platform_interface 2.1.0
    │ │ ├── platform 3.1.1
    │ │ ├── flutter...
    │ │ └── plugin_platform_interface...
    │ ├── path_provider_windows 2.2.0
    │ │ ├── win32 5.0.6
    │ │ │ └── ffi...
    │ │ ├── ffi...
    │ │ ├── flutter...
    │ │ ├── path...
    │ │ └── path_provider_platform_interface...
    │ └── flutter...
    ├── provider 6.0.5
    │ ├── nested 1.0.0
    │ │ └── flutter...
    │ ├── collection...
    │ └── flutter...
    ├── shared_preferences 2.2.0
    │ ├── shared_preferences_android 2.2.0
    │ │ ├── flutter...
    │ │ └── shared_preferences_platform_interface...
    │ ├── shared_preferences_foundation 2.3.3
    │ │ ├── flutter...
    │ │ └── shared_preferences_platform_interface...
    │ ├── shared_preferences_linux 2.3.0
    │ │ ├── file 6.1.4
    │ │ │ ├── meta...
    │ │ │ └── path...
    │ │ ├── flutter...
    │ │ ├── path...
    │ │ ├── path_provider_linux...
    │ │ ├── path_provider_platform_interface...
    │ │ └── shared_preferences_platform_interface...
    │ ├── shared_preferences_platform_interface 2.3.0
    │ │ ├── plugin_platform_interface 2.1.5
    │ │ │ └── meta...
    │ │ └── flutter...
    │ ├── shared_preferences_web 2.2.0
    │ │ ├── flutter_web_plugins 0.0.0
    │ │ │ ├── characters...
    │ │ │ ├── collection...
    │ │ │ ├── flutter...
    │ │ │ ├── material_color_utilities...
    │ │ │ ├── meta...
    │ │ │ ├── vector_math...
    │ │ │ └── web...
    │ │ ├── flutter...
    │ │ └── shared_preferences_platform_interface...
    │ ├── shared_preferences_windows 2.3.0
    │ │ ├── file...
    │ │ ├── flutter...
    │ │ ├── path...
    │ │ ├── path_provider_platform_interface...
    │ │ ├── path_provider_windows...
    │ │ └── shared_preferences_platform_interface...
    │ └── flutter...
    └── url_launcher 6.1.12
    ├── url_launcher_android 6.0.38
    │ ├── flutter...
    │ └── url_launcher_platform_interface...
    ├── url_launcher_ios 6.1.4
    │ ├── flutter...
    │ └── url_launcher_platform_interface...
    ├── url_launcher_linux 3.0.5
    │ ├── flutter...
    │ └── url_launcher_platform_interface...
    ├── url_launcher_macos 3.0.6
    │ ├── flutter...
    │ └── url_launcher_platform_interface...
    ├── url_launcher_platform_interface 2.1.3
    │ ├── flutter...
    │ └── plugin_platform_interface...
    ├── url_launcher_web 2.0.18
    │ ├── flutter...
    │ ├── flutter_web_plugins...
    │ └── url_launcher_platform_interface...
    ├── url_launcher_windows 3.0.7
    │ ├── flutter...
    │ └── url_launcher_platform_interface...
    └── flutter...

  • output of - flutter doctor -v

  • [✓] Flutter (Channel stable, 3.13.0, on macOS 13.4.1 22F770820d darwin-arm64, locale en-IN)
    • Flutter version 3.13.0 on channel stable at /Users/kundankumar/kundan/FlutterDev/sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision efbf63d9c6 (35 hours ago), 2023-08-15 21:05:06 -0500
    • Engine revision 1ac611c64e
    • Dart version 3.1.0
    • DevTools version 2.25.0

[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/kundankumar/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 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1

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

[✓] Android Studio (version 2022.1)
• 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.15+0-b2043.56-8887301)

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

[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.4.1 22F770820d darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 115.0.5790.170

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 1 category.

Steps to reproduce

  1. Build an add to app flutter module
  2. Create a framework from that module for IOS
  3. Add that framework to Native IOS application
  4. Run the IOS application, object box will not working
  5. It is creating the following error
unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
#0      PathProviderApi.getDirectoryPath (package:path_provider_foundation/messages.g.dart:42)
<asynchronous suspension>
#1      getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:121)
<asynchronous suspension>
#2      ObjectBox.create (package:flutter_lib/objectBox/ObjectBoxManager.dart:28)

For reference - https://docs.flutter.dev/add-to-app

Expected behavior

The Object box should work fine as its working when running directly from flutter to device

Code

Logs, stack traces

_2023-08-17 17:41:59.439466+0530 ***********[1927:1023140] flutter: ObjectBoxIssue: message: [0]
2023-08-17 17:41:59.442221+0530 ***********[1927:1023140] flutter: Flutter: setThemeMode-> Brightness.light
2023-08-17 17:41:59.446920+0530 ***********[1927:1023140] flutter: Flutter: setThemeMode-> Brightness.light
2023-08-17 17:41:59.447347+0530 ***********[1927:1023140] flutter: ObjectBoxIssue: getDirectoryPath: arg_type: DirectoryType.applicationDocuments
2023-08-17 17:41:59.447382+0530 ***********[1927:1023140] flutter: ObjectBoxIssue: message: [0]
2023-08-17 17:41:59.447824+0530 ***********[1927:1022736] Flutter : response ACTION_DEVICE_INFO - nil)
2023-08-17 17:41:59.448239+0530 ***********[1927:1023140] flutter: ObjectBoxIssue: getDirectoryPath: replyList: null
2023-08-17 17:41:59.449447+0530 ***********[1927:1023140] [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
#0      PathProviderApi.getDirectoryPath (package:path_provider_foundation/messages.g.dart:42)
<asynchronous suspension>
#1      getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:121)
<asynchronous suspension>
#2      ObjectBox.create (package:flutter_lib/objectBox/ObjectBoxManager.dart:28)
<asynchronous suspension>
#3      initObjectBox (package:flutter_lib/main.dart:66)
<asynchronous suspension>
Push Token:579793f10d2722900611b45ba7ad8ae47712a9af907edbc08ad8402edfe47ae6
2023-08-17 17:41:59.452891+0530 ***********[1927:1023140] flutter: ObjectBoxIssue: getDirectoryPath: replyList: null
2023-08-17 17:41:59.453239+0530 ***********[1927:1023140] [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
#0      PathProviderApi.getDirectoryPath (package:path_provider_foundation/messages.g.dart:42)
<asynchronous suspension>
#1      getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:121)
<asynchronous suspension>
#2      ObjectBox.create (package:flutter_lib/objectBox/ObjectBoxManager.dart:28)
<asynchronous suspension>
#3      initObjectBox (package:flutter_lib/main.dart:66)
<asynchronous suspension>
#4      getDlManager (package:flutter_lib/main.dart:52)
<asynchronous suspension>
#5      _ApplicationState.initEventManager (package:flutter_lib/main.dart:144)
<asynchronous suspension>_

Additional context

@kundankuldeep kundankuldeep added the bug Something isn't working label Aug 17, 2023
@greenrobot-team
Copy link
Member

This crash originates in the path_provider package, not objectbox:

2023-08-17 17:41:59.449447+0530 Jeevansathi[1927:1023140] [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
#0      PathProviderApi.getDirectoryPath (package:path_provider_foundation/messages.g.dart:42)
<asynchronous suspension>
#1      getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:121)
<asynchronous suspension>
#2      ObjectBox.create (package:flutter_lib/objectBox/ObjectBoxManager.dart:28)

After googling a bit there does not appear to be a single cause (might be permissions, might be outdated versions). So please have a look yourself. If you solve this we would love to hear your solution in case other users are affected by this.

@greenrobot-team greenrobot-team added question How to do something/general question more info required Needs more info to become actionable. Auto-closed if no response. and removed bug Something isn't working labels Aug 21, 2023
@greenrobot-team greenrobot-team changed the title PlatformException(channel-error, Unable to establish connection on channel., null, null Add-to-app on iOS: crash of PathProvider (PlatformException) Aug 21, 2023
@kundankuldeep
Copy link
Author

Thanks @greenrobot-team, Debugging the same!! Will update the solution when we found solution to this.

@github-actions github-actions bot removed the more info required Needs more info to become actionable. Auto-closed if no response. label Aug 22, 2023
@greenrobot-team greenrobot-team added the more info required Needs more info to become actionable. Auto-closed if no response. label Aug 22, 2023
@github-actions
Copy link

Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2023
@kundankuldeep
Copy link
Author

This Issue currently active on path provider, and no solution is provided from the developer yet.

but We have managed to resolve this issue by getting the path from native IOS Platform through channel while creating the box.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info required Needs more info to become actionable. Auto-closed if no response. question How to do something/general question
Projects
None yet
Development

No branches or pull requests

2 participants