更新2020/12/12问题已解决。出现此问题是因为我在插件中编辑了清单。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tungwang.tappayflutterplugin">
<!-- <application-->
<!-- xmlns:tools="http://schemas.android.com/tools"-->
<!-- tools:node="replace"-->
<!-- />-->
</manifest>
我对内容进行评论,然后将其迁移到我的应用程序清单中。
<application
android:name=".Application"
android:label="Home Go"
android:icon="@drawable/app_icon"
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:label">
它工作得很好。
问题
我每次都在安卓上遇到这个错误,我无法在我的应用程序中接收消息。我读过很多关于stackoverflow的答案,但仍然面临这个错误。我真的对这个错误感到困惑。有人能帮我吗?非常感谢。
我在android/app中添加了谷歌服务.json在此处输入图像描述
这是我的项目级build.gradle.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//FCM
// Add the google services classpath
classpath 'com.google.gms:google-services:4.3.2'
}
}
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
}
这是我的应用程序级build.gradle.
def localProperties = new Properties()
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: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.viainno.homego"
minSdkVersion 18
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-messaging:20.2.4'
implementation 'com.android.support:multidex:1.0.3'
}
//FCM
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
您试图在未初始化的情况下获取Firebase的实例。请在尝试获取Firebase实例之前添加FirebaseApp.initialize()
。