flutter: android manifest doesn't read kotlin file (Application.kt) - flutter

I'm trying to imply firebase cloud messaging to my app and I have tried to add both MainActvity.kt and Application.kt to my project and i didnt have kotlin installed on my project so i downloaded kotlin plugin then restarted my IDE then added the .kt files, however when i try to add the application.kt to my android manifest the app won't build and says "app" has stopped, but without it it works fine, what am i doing wrong?
heres my application.kt code
package com.example.tamataapp
import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;
class Application : FlutterApplication(), PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this)
}
override fun registerWith(registry: PluginRegistry) {
GeneratedPluginRegistrant.registerWith(registry)
}
}
and my MainActivity.kt
package com.example.tamataapp
import android.os.Bundle
import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this)
// getWindow().addFlags(LayoutParams.FLAG_SECURE)
}
}
and here is my android manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tamataapp">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. "io.flutter.app.FlutterApplication" -->
<application
android:name=".Application"
android:label="tamataapp"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="default_notification_channel_id”>Channel ID"/>
<!-- 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"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</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" />
<service
android:name=".java.MyFirebaseMessagingService"
android:exported="false">
</service>
</application>
</manifest>

Related

Flutter : No implementation found for method login on channel app.meedu/flutter_facebook_auth

I am trying to use facebook auth in myy app with flutter.
I did all things in documentation.
also I tried to find solution here but nothing helped me ,for example this post and this post
I add this strings.xml :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="facebook_app_id">xxxxxxxxxxx</string>
<string name="fb_login_protocol_scheme">fbxxxxxxxxxxxx</string>
<string name="facebook_client_token">xxxxxxxxxxxxxxxxx</string>
<string name="app_name">xxxx</string>
</resources>
in AndroidManifest.xml I add this :
<uses-permission android:name="android.permission.INTERNET"/> // before application
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="#string/facebook_client_token"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<queries>
<provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
my function :
final LoginResult result = await FacebookAuth.instance.login();
if (result.status == LoginStatus.success) {
accessToken = result.accessToken!;
isLogined = true;
final userData = await FacebookAuth.instance.getUserData();
} else {
print(result.status);
print(result.message);
}
I get this error [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method login on channel app.meedu/flutter_facebook_auth)
Usually the "No implementation" error is caused when you add a new package and do hot reload, or when the platform isn't supported. Try running the app from cold start.
If it still fails, I recommend using firebase_auth package for authentication since it supports multiple providers including Facebook.
From https://facebook.meedu.app/docs/5.x.x/android (where you can also find more relevant info):
Upon installation of this plugin, configuration is needed on Android before running the project again. If this is not done, an error of No implementation found would show because the Facebook SDK on Android would throw an Exception error if the configuration is not yet defined. This error also locks the other plugins in your project, so if the plugin is not yet needed, either remove it or comment it out from the pubspec.yaml file.
So, when you add the flutter_facebook_auth plugin, you have to add in configuration to avoid this error. This includes
in /android/app/src/main/res/values/strings.xml:
<string name="facebook_app_id">{your-app-id}</string>
<string name="facebook_client_token">YOUR_CLIENT_TOKEN</string>
in /android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="#string/facebook_client_token"/>
for Android API 30+ also add
<manifest package="com.example.app">
<queries>
<provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
</queries>
...
</manifest>
and Associate Your Package Name and Default Class with Your App in Facebook.
This got me past the error you mentioned.

Exception: The plugin analog_clock could not be built

I am trying to add map on my dashboard screen.
my map code is look like this
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Maps Sample App'),
backgroundColor: Colors.green[700],
),
body: Stack(
children: <Widget>[
GoogleMap(initialCameraPosition: CameraPosition(target:
LatLng(-33.870840,151.206286),
zoom: 12)
)
],
)
),
);
i got it from this link.
when i run my code it gives me this error
Plugin project :location_web not found. Please update settings.gradle.
i resolved it by using this solution (Using Peter Haddad solution)
dependencies on pubspec.yaml file are
dependencies:
intl: ^0.17.0
flutter:
sdk: flutter
analog_clock: ^0.0.1
get_it: ^6.1.1
url_launcher: ^5.4.11
shared_preferences: ^0.5.1+2
dio:
fluttertoast:
google_maps_flutter: ^0.5.30
location: ^3.0.2
and my settings.gradle file code is
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
and here it shows error, i am using analog clock on other screen too.
------update
here is AndriodManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.attendance_system_app">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:label="attendance_system_app"
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="#string/default_notification_channel_id"/>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyDSBu24ZIgKe96hi27uK-cGugvpheAgaKQ"/>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
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"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<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" />
</application>
</manifest>
Update:
logs when run flutter doctor and flutter upgrade command
here are the logs when i run command on cmd
------update
here is my manifest file, after kernel error happened
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.attendance_system_app">
<application
android:label="attendance_system_app"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
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"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<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" />
</application>
</manifest>
Please help me how to fix it.
The problem is not for the analog_clock. It is for the location or google_maps_flutter
you added the default_notification_channel_id in the manifest. But this is not found in the resource.
Update:
For those who are not able to find "string.xml", you can find it under android>app>src>main>res>values. It is not the same as styles.xml. If you do not have one yet, you can create one:
Right-click the "values" folder,
create New Values Resource with string name,
and create a string with name fcm_default_channel

Deployed Flutter application to Google Play Store but it's stuck at the splash screen

Deployed Flutter application to Google Play Store but it's stuck at the splash screen and never open
I did match my AppID and still facing the same issue
Here is my manifest.xml:
<!-- TODO: Changed by Parveen Before merge 1 -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mrbox.store">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--
io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here.
-->
<!-- TODO: Add By Parveen before merge 1 -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Mr.Box Store"
android:usesCleartextTraffic="true"
android:icon="#mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
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"
/>
<!--
Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame.
-->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!--
TODO: Changed by parveen before merge 1
android:name="default-url"
android:value="https://inspireui.com"
-->
<meta-data
android:name="default-url"
android:value="https://www.mrboxstore.com" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- TODO: Changed by parveen before merge 1 android:value="inspireui.com" -->
<data android:scheme="https"
android:host="mrboxstore.com" />
<data android:scheme="http" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/logo" />
<!--
Set color used with incoming notification messages. This is used when no color is set for the incoming
notification message.
-->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/notiColor" />
<!-- Google map and Admod setup -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/api_key" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/admob_api" />
<!-- Facebook Login configuration -->
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:exported="true" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</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" />
</application>
</manifest>
Things to try
Make sure flutter doctor -v runs without ANY complaints
Edit android/gradle.properties and add the flag: android.bundle.enableUncompressedNativeLibs=false
Do a flutter clean command
Try creating a release build using flutter build appbundle
Test Locally / Offline
download bundletool
Generate a set of APKs from your app bundle, following this guide
Deploy the app to your connected device(s) following this Guide
Works?
Upload your bundle to Google Play using the internal test track, or the alpha or beta channels to test the bundle before releasing it in production
Instructions for doing this can be found here
Good Luck :)
Because it is not working after uploading on google play. then there might be some issue with your app signing. You can follow the steps here
I have faced issues like this when I used facebook login sdk, so I would suggest checking following:
Check if you have signed the apk/appbundle with proper release keystore
Check if you have opt in for google's automatic signing on playstore while deploying app
2.1 If yes then it will change the sha-1 value which is used in facebook app for authentication, for it to work use the one generated by google in playstore
Assuming that you publish an App Bundle (.aab file) the issue can be related to the format itself since it is not testable via IDE. E.g. when running the app in Release mode on a device .apk is created and provisioned to it, not .aab.
What I did in the past to troubleshoot .aab (also had failures only with GPlay version, local Debug and Release modes worked fine) was to use Firebase Test Lab. You can run automated monkey tests on 5 physical devices and 15 virtual devices every day free-of-charge. Just log in to Firebase Console, cretae an empty project, go to Test, upload your .aab file, select devices (it's worth also to choose different locales) and wait for completion. After that check logs in test results, you might find answers there (in my cases there was an issue with localization resources which got broken while producing .aab release package).
This option can be esier/faster than splitting .aab locally with comand line into APKs and testing on a local device.
In my experience, try to check your database(sqlite) if created. Try to replace the path and check if the database is created properly.

Flutter android_alarm_manager doesn't load flutter_audio_query plugin for callback

I am working on a rather simple alarm app that uses android_alarm_manager to schedule the alarms and flutter_audio_query to gather information about the music I need to make things work. When the alarm goes off I need to have flutter_audio_query loaded to be able to access the file paths of the sound files I want to use.
The issue I am facing currently is the plugin not being loaded inside the callback, causing a MissingPluginException. This does not appear to be the issue with the PathProvider plugin for example (which I initially intended to use for the demo below).
MCVE attempt (created a new Flutter project with Kotlin Support, AndroidX under Flutter Version 1.12.13+hotfix.8; full repository here):
main.dart:
import 'package:android_alarm_manager/android_alarm_manager.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_audio_query/flutter_audio_query.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await AndroidAlarmManager.initialize();
runApp(MyApp());
Scheduler().setupAlarm();
// Runs because the FAQ plugin is loaded correctly.
final demoSongList = await FlutterAudioQuery().getSongs();
print('Main function: ${demoSongList.length}');
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Center(child: Text('Sample Text', textDirection: TextDirection.ltr,));
}
}
class Scheduler {
setupAlarm() async {
print('Setting up alarm!');
final success = await AndroidAlarmManager.oneShot(Duration(seconds: 3), 42, callback);
print(success);
}
static callback() async {
// Requires FAQ plugin to be loaded which it isn't.
final songs = await FlutterAudioQuery().getSongs();
print('Callback ${songs.length}!');
}
}
pubspec.yaml
name: stack_overflow_demo
description: A Demo Application demonstrating the issue with android_alarm_manager and plugins
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
android_alarm_manager: ^0.4.5+3
flutter_audio_query: ^0.3.3
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.geisterfurz007.stack_overflow_demo">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="stack_overflow_demo"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<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" />
<service
android:name="io.flutter.plugins.androidalarmmanager.AlarmService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"/>
<receiver
android:name="io.flutter.plugins.androidalarmmanager.AlarmBroadcastReceiver"
android:exported="false"/>
<receiver
android:name="io.flutter.plugins.androidalarmmanager.RebootBroadcastReceiver"
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-filter>
</receiver>
</application>
</manifest>
If more files are required, let me know; I will add them as soon as I can!
From my understanding with Android Embedding V2 (as declared in the AndroidManifest.xml), all plugins should be loaded through reflection and creating my own Application to load the plugins should not be required.
Now for the actual question of this question: What causes the FlutterAudioQuery Plugin to not be loaded in the callback and how do I change this so I can use it when the alarm runs?
For transparency: After rather low views on this question after a day, I decided to open up a Github issue in the flutter repo here.
I think the problem is that flutter_audio_query does not support the new plugin APIs yet. Check this page in the flutter documentation.
I had a quick look at the flutter_audio_query source and it doesn´t seem to implement the FlutterPlugin interface (Upgrade Step 1 in the documentation).
There is a new version of audio_query_plugin available and appears the new Flutter V2 embedding API is working with.
By CHANGELOG.md

Flutter - Local Notifications fail in release mode

I added the flutter_local_notifications plugin to schedule notifications. In the debug version everything works well for both emulators and real devices.
However, when I build the app
flutter build apk --split-per-abi
and install the package on a device and run the app, when it comes to the code part that marks the notification (I supposed...) , the app crashes
How do I find out what's wrong?
I followed the plugin developers instructions and changed the manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.explika">
<uses-permission android:name="android.permission.INTERNET" />
<!-- Tudo relacionado com as notificações -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<!-- Fim relacionado com notificações -->
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Explika"
android:icon="#mipmap/ic_launcher">
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in #style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
I found out what is causing the application to crash:
[ERROR: flutter / shell / platform / android / platform_view_android_jni.cc (39)] java.lang.AssertionError: java.lang.NoSuchFieldException: Drawable
However, this only happened in the Release version. The solution consists of customizing the ProGuard configuration file and the build.gradle file following the instructions on the plugin page.
I didn't do these steps because until then the Release version worked without problems and because I thought ProGuard configuration file would only be necessary in case want to publish on the Play Store.