我添加了 flutter_local_notifications 插件来安排通知。在 debug版本中,一切对于仿真器和真实设备都适用。
但是,当我构建应用程序时
flutter build apk --split-per-abi
然后将软件包安装在设备上并运行应用程序,当涉及标记通知的代码部分(我认为...)时,应用程序崩溃
如何找出问题所在?
我遵循了插件开发人员的说明,并更改了清单文件:
<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>
答案 0 :(得分:0)
我发现了导致应用程序崩溃的原因:
[错误:flutter / shell / platform / android / platform_view_android_jni.cc(39)] java.lang.AssertionError:java.lang.NoSuchFieldException:Drawable
但是,这仅在发行版中发生。该解决方案包括按照插件页面上的说明来自定义ProGuard配置文件和build.gradle文件。 我之所以没有执行这些步骤,是因为在此之前发行版一直可以正常工作,并且因为我认为ProGuard配置文件仅在要发布到Play商店的情况下才是必需的。