Flutter 颤振应用程序在清单中找不到应用程序
我已经尝试将Firebase消息添加到我的Flatter应用程序中,根据教程,我应该将自定义应用程序名称添加到清单文件中 问题 应用程序无法启动,因为Flatter找不到我的自定义应用程序文件 原因 我已尝试将FlatterFire/Firebase云消息与Flatter集成 要求 我所关心的是在Flitter应用程序上接收推送通知(前台+后台),如果这不是正确的方法,请告诉我如何为Android设备启用此功能 日志和输出 我的舱单是Flutter 颤振应用程序在清单中找不到应用程序,flutter,firebase-cloud-messaging,android-multidex,Flutter,Firebase Cloud Messaging,Android Multidex,我已经尝试将Firebase消息添加到我的Flatter应用程序中,根据教程,我应该将自定义应用程序名称添加到清单文件中 问题 应用程序无法启动,因为Flatter找不到我的自定义应用程序文件 原因 我已尝试将FlatterFire/Firebase云消息与Flatter集成 要求 我所关心的是在Flitter应用程序上接收推送通知(前台+后台),如果这不是正确的方法,请告诉我如何为Android设备启用此功能 日志和输出 我的舱单是 package="com.blabla.b
package="com.blabla.blabla">
<!-- Default is android:name="io.flutter.app.FlutterApplication" -->
<!-- FOR PUSH NOIFICATION IN BACKGROUND android:name=".Application" -->
<application
android:name=".Application"
android:label="BlaBla"
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">
<!-- this is the push notification intent -->
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
我的具体(app->build.gradle)如下
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // Google Services plugin
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.bla.bla"
minSdkVersion 21
targetSdkVersion 30
// multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86 and x86_64.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "x86", "x86_64", "armeabi", "armeabi-v7a", "arm64-v8a"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk true
}
}
}
flutter {
source '../..'
}
dependencies {
// implementation "androidx.multidex:multidex:2.0.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:26.6.0')
// Declare the dependencies for the Firebase Cloud Messaging and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-messaging-ktx:21.0.1'
// implementation 'com.google.firebase:firebase-analytics-ktx'
}
这是通用的版本,格雷德尔
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.5' // Google Services plugin
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是每次启动的控制台输出
E/AndroidRuntime(31070): java.lang.RuntimeException: Unable to instantiate application com.bla.bla.Application: java.lang.ClassNotFoundException: Didn't find class "com.bla.bla.Application" on path: DexPathList[[zip file "/data/app/com.bla.bla-bPPOfcyKzIbhjyMWE3Q9NQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.bla.bla-bPPOfcyKzIbhjyMWE3Q9NQ==/lib/arm64, /data/app/com.bla.bla-bPPOfcyKzIbhjyMWE3Q9NQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
E/AndroidRuntime(31070): at android.app.LoadedApk.makeApplication(LoadedApk.java:1231)
E/AndroidRuntime(31070): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
E/AndroidRuntime(31070): at android.app.ActivityThread.access$1300(ActivityThread.java:219)
E/AndroidRuntime(31070): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
E/AndroidRuntime(31070): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(31070): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(31070): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime(31070): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(31070): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
E/AndroidRuntime(31070): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
我不知道还能做什么!!我花了无数个小时试图解决这个问题,如果有人知道如何解决这个问题,我将不胜感激
当前运行在Google Pixel 2 Android 10设备上。请尝试修改您的
AndroidManifest.xml
文件,如下所示。这是有效的。
这仅适用于
我的坏
我不小心把Application.kt
文件放在android
app
文件夹中,而不是android
app
src
你的包名
一旦我将定制的
应用程序.kt
移到MainActivity.kt
旁边,一切似乎都很好 谢谢你的回答,但我忽略了一个简单的错误。。。
E/AndroidRuntime(31070): java.lang.RuntimeException: Unable to instantiate application com.bla.bla.Application: java.lang.ClassNotFoundException: Didn't find class "com.bla.bla.Application" on path: DexPathList[[zip file "/data/app/com.bla.bla-bPPOfcyKzIbhjyMWE3Q9NQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.bla.bla-bPPOfcyKzIbhjyMWE3Q9NQ==/lib/arm64, /data/app/com.bla.bla-bPPOfcyKzIbhjyMWE3Q9NQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
E/AndroidRuntime(31070): at android.app.LoadedApk.makeApplication(LoadedApk.java:1231)
E/AndroidRuntime(31070): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
E/AndroidRuntime(31070): at android.app.ActivityThread.access$1300(ActivityThread.java:219)
E/AndroidRuntime(31070): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
E/AndroidRuntime(31070): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(31070): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(31070): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime(31070): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(31070): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
E/AndroidRuntime(31070): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
<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>
</activity>