ARTICLE AD BOX
I am unable to build with awesome_notifications, using the receivers specified in the readme documentation. In that readme file it says:
Also, to allow the schedules to be recreated when the device is restarted, you need to add these permissions and these listeners on your AndroidManifest file:
<manifest> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <application> <receiver android:name="me.carda.awesome_notifications.core.broadcasters.receivers.ScheduledNotificationReceiver" android:exported="true" /> <receiver android:name="me.carda.awesome_notifications.core.broadcasters.receivers.RefreshSchedulesReceiver" android:exported="true"> ...However, when I add the code sample to my AndroidManifest, Android Studio gives the warning "Class referenced in the manifest, me.carda.awesome_notifications.core.broadcasters.receivers.RefreshSchedulesReceiver, was not found in the project or the libraries". Then when I compile I get the error that flutter is "unable to instatiate receiver". Any ideas what's going on? I am able to compile my code without these receivers, but the appearance of the notification on the second and following days is unreliable.
Here's my full AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <application android:label="Reading\nPlan" android:name="${applicationName}" android:icon="@mipmap/ic_launcher"> <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:taskAffinity="" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"> <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <!-- Don't delete the meta-data below. This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> <meta-data android:name="flutterEmbedding" android:value="2" /> <receiver android:name="me.carda.awesome_notifications.core.broadcasters.receivers.ScheduledNotificationReceiver" android:exported="true" /> <receiver android:name="me.carda.awesome_notifications.core.broadcasters.receivers.RefreshSchedulesReceiver" android:exported="true"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver> </application> <queries> <intent> <action android:name="android.intent.action.PROCESS_TEXT"/> <data android:mimeType="text/plain"/> </intent> </queries> </manifest>And the output from the compile is here:
Resolving dependencies... Downloading packages... characters 1.4.0 (1.4.1 available) leak_tracker 11.0.1 (11.0.2 available) matcher 0.12.17 (0.12.18 available) material_color_utilities 0.11.1 (0.13.0 available) meta 1.16.0 (1.17.0 available) path_provider_android 2.2.18 (2.2.22 available) path_provider_foundation 2.4.2 (2.5.1 available) test_api 0.7.6 (0.7.8 available) url_launcher_android 6.3.18 (6.3.28 available) url_launcher_ios 6.3.4 (6.3.6 available) url_launcher_linux 3.2.1 (3.2.2 available) url_launcher_macos 3.2.3 (3.2.5 available) url_launcher_windows 3.1.4 (3.1.5 available) Got dependencies! 13 packages have newer versions incompatible with dependency constraints. Try `flutter pub outdated` for more information. Launching lib/main.dart on SM S721B in debug mode... Running Gradle task 'assembleDebug'... ✓ Built build/app/outputs/flutter-apk/app-debug.apk Installing build/app/outputs/flutter-apk/app-debug.apk... D/FlutterJNI(14062): Beginning load of flutter... D/FlutterJNI(14062): flutter (null) was loaded normally! I/flutter (14062): [IMPORTANT:flutter/shell/platform/android/android_context_vk_impeller.cc(62)] Using the Impeller rendering backend (Vulkan). E/AndroidRuntime(14062): FATAL EXCEPTION: main E/AndroidRuntime(14062): Process: com.example.bible_reading_plan, PID: 14062 E/AndroidRuntime(14062): java.lang.RuntimeException: Unable to instantiate receiver me.carda.awesome_notifications.core.broadcasters.receivers.RefreshSchedulesReceiver: java.lang.InstantiationException: java.lang.Class<me.carda.awesome_notifications.core.broadcasters.receivers.RefreshSchedulesReceiver> cannot be instantiated E/AndroidRuntime(14062): at android.app.ActivityThread.handleReceiver(ActivityThread.java:5629) E/AndroidRuntime(14062): at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0) E/AndroidRuntime(14062): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2904) E/AndroidRuntime(14062): at android.os.Handler.dispatchMessage(Handler.java:110) E/AndroidRuntime(14062): at android.os.Looper.loopOnce(Looper.java:273) E/AndroidRuntime(14062): at android.os.Looper.loop(Looper.java:363) E/AndroidRuntime(14062): at android.app.ActivityThread.main(ActivityThread.java:10060) E/AndroidRuntime(14062): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(14062): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632) E/AndroidRuntime(14062): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975) E/AndroidRuntime(14062): Caused by: java.lang.InstantiationException: java.lang.Class<me.carda.awesome_notifications.core.broadcasters.receivers.RefreshSchedulesReceiver> cannot be instantiated E/AndroidRuntime(14062): at java.lang.Class.newInstance(Native Method) E/AndroidRuntime(14062): at android.app.AppComponentFactory.instantiateReceiver(AppComponentFactory.java:110) E/AndroidRuntime(14062): at androidx.core.app.CoreComponentFactory.instantiateReceiver(CoreComponentFactory.java:59) E/AndroidRuntime(14062): at android.app.ActivityThread.handleReceiver(ActivityThread.java:5622) E/AndroidRuntime(14062): ... 9 more Error connecting to the service protocol: failed to connect to http://127.0.0.1:53026/ywRYibvU2gU=/ DartDevelopmentServiceException: WebSocketChannelException: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:53026/ywRYibvU2gU=/ws The Dart compiler exited unexpectedly.And, in case it's useful, here's my pubspec.yaml:
name: "bible_reading_plan" description: "An app to help you follow a bible reading plan" # The following line prevents the package from being accidentally published to # pub.dev using `flutter 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 is used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. version: 1.0.0+1 environment: sdk: '>=3.0.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions # consider running `flutter pub upgrade --major-versions`. Alternatively, # dependencies can be manually updated by changing the version numbers below to # the latest version available on pub.dev. To see which dependencies have newer # versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 intl: ^0.20.1 path_provider: ^2.1.5 provider: ^6.1.2 url_launcher: ^6.3.1 awesome_notifications_core: ^0.10.0 awesome_notifications: ^0.10.1 dev_dependencies: flutter_test: sdk: flutter # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^6.0.0 ## Force the usage of a modern version of the web package #dependency_overrides: # web: ^1.3.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter packages. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: assets: - assets/images/ - assets/icons/ # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/to/resolution-aware-images # For details regarding adding assets from package dependencies, see # https://flutter.dev/to/asset-from-package # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a # "family" key with the font family name, and a "fonts" key with a # list giving the asset and other descriptors for the font. For # example: # fonts: # - family: Schyler # fonts: # - asset: fonts/Schyler-Regular.ttf # - asset: fonts/Schyler-Italic.ttf # style: italic # - family: Trajan Pro # fonts: # - asset: fonts/TrajanPro.ttf # - asset: fonts/TrajanPro_Bold.ttf # weight: 700 # # For details regarding fonts from package dependencies, # see https://flutter.dev/to/font-from-package