'package:home_widget/home_widget_callback_dispatcher.dart' not found
I am trying to use the backgroundCallback to refresh my widget by pressing an image on the widget. It works fine on debug mode, however when I build apk or run flutter run --release --verbose I get the error below (well in apk I can't see the error but it does not work either).
I get this error after tapping the image with the callback URI:
[ +9 ms] E/flutter (14277): [ERROR:flutter/shell/common/shell.cc(88)] Dart Error: Dart_LookupLibrary: library 'package:home_widget/home_widget_callback_dispatcher.dart' not found. [ ] E/flutter (14277): [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function. [ ] E/flutter (14277): [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint. [ ] E/flutter (14277): [ERROR:flutter/runtime/runtime_controller.cc(386)] Could not create root isolate. [ ] E/flutter (14277): [ERROR:flutter/shell/common/shell.cc(605)] Could not launch engine with configuration. [ +28 ms] W/FlutterJNI(14277): FlutterJNI.loadLibrary called more than once [ ] W/FlutterJNI(14277): FlutterJNI.prefetchDefaultFontManager called more than once [ ] W/FlutterJNI(14277): FlutterJNI.init called more than once [ +8 ms] E/flutter (14277): [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function. [ ] E/flutter (14277): [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint. [ ] E/flutter (14277): [ERROR:flutter/runtime/runtime_controller.cc(386)] Could not create root isolate. [ ] E/flutter (14277): [ERROR:flutter/shell/common/shell.cc(605)] Could not launch engine with configuration.
That makes no sense to me. What confuses me is that it is working fine in Debug. You can see here that the file is in my package beside the other one.
Doctor summary:
[✓] Flutter (Channel master, 3.4.0-19.0.pre.35, on Microsoft Windows [Version 10.0.22000.856], locale en-CA) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Chrome - develop for the web [✗] Visual Studio - develop for Windows ✗ Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [✓] Android Studio (version 2021.2) [✓] VS Code, 64-bit edition (version 1.67.2) [✓] Connected device (4 available) [✓] HTTP Host Availability
I'm getting the error too. Did you find a solution?
I found a solution.
This is a modification of the original source.
.pub-cache/hosted/pub.dartlang.org/home_widget-0.1.6/lib/home_widget_callback_dispatcher.dart
void callbackDispatcher() { ...
to
@pragma('vm:entry-point') // <- add
void callbackDispatcher() { ...
HomeWidget.registerBackgroundCallback(backgroundCallback);
@pragma('vm:entry-point') // <- add
void backgroundCallback(Uri? data) async {
updateWidget(data);
}
I have the same problem. this solution worked for me
I also fixed it like this. This should be included in an upcoming update, in my opinion.
I had made a pull request https://github.com/ABausG/home_widget/pull/99 approved by author of this project but it wasn't merged yet.
So you can change the dependencies from the version to my branch reference if you want to resolve this issue TEMPORARILY.
Following is an example: Modify the reference to home_widget in this section
# pubspec.yaml
#...
dependencies:
#...
- home_widget: ^0.1.6
+ home_widget:
+ git:
+ url: https://github.com/linziyou0601/home_widget.git
+ ref: BackgroundDispatcherVmEntryError
#...
I don't work for me BUT I added 2 lines of code in build.gradle(app) and it worked
buildTypes {
release {
shrinkResources false <--- first line
minifyEnabled false <--- second line
signingConfig signingConfigs.release
}
}
This is my version of flutter
Flutter 3.3.10 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 135454af32 (5 weeks ago) • 2022-12-15 07:36:55 -0800
Engine • revision 3316dd8728
Tools • Dart 2.18.6 • DevTools 2.15.0