Flutter 尽管我对android x进行了修改,但为什么firebase消息无法正常工作

Flutter 尽管我对android x进行了修改,但为什么firebase消息无法正常工作,flutter,firebase-cloud-messaging,Flutter,Firebase Cloud Messaging,我在使用fire base消息包时遇到问题,出现以下错误。我已经尝试了所有张贴的解决方案。我尝试了颤振清洁,升级min sdk到28,并遵守了一个,但这不起作用 但对我来说什么都不管用,我希望能在这方面找到帮助,这浪费了我一天的时间。多谢各位 E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\fireba

我在使用fire base消息包时遇到问题,出现以下错误。我已经尝试了所有张贴的解决方案。我尝试了颤振清洁,升级min sdk到28,并遵守了一个,但这不起作用

但对我来说什么都不管用,我希望能在这方面找到帮助,这浪费了我一天的时间。多谢各位

E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\firebasemessaging\FirebaseMessagingPlugin.java:12: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\firebasemessaging\FirebaseMessagingPlugin.java:13: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^
E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\firebasemessaging\FlutterFirebaseInstanceIDService.java:9: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^

                                 ^
E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\firebasemessaging\FirebaseMessagingPlugin.java:81: error: cannot find symbol
  @NonNull
   ^
  symbol:   class NonNull
  location: class FirebaseMessagingPlugin
E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\firebasemessaging\FirebaseMessagingPlugin.java:57: error: cannot find symbol
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(registrar.context());
    ^
  symbol:   class LocalBroadcastManager
  location: class FirebaseMessagingPlugin
E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\firebasemessaging\FirebaseMessagingPlugin.java:57: error: cannot find symbol
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(registrar.context());
                                    ^
  symbol:   variable LocalBroadcastManager
  location: class FirebaseMessagingPlugin
E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\firebasemessaging\FirebaseMessagingPlugin.java:122: error: cannot find symbol
                public void onComplete(@NonNull Task<InstanceIdResult> task) {
                                        ^
 );
    ^
  symbol:   variable LocalBroadcastManager
  location: class FlutterFirebaseInstanceIDService
E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\firebasemessaging\FlutterFirebaseMessagingService.java:27: error: cannot find symbol
    LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
    ^
  symbol:   variable LocalBroadcastManager
  location: class FlutterFirebaseMessagingService
Note: E:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-2.2.0+1\android\src\main\java\io\flutter\plugins\firebasemessaging\FlutterFirebaseInstanceIDService.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
10 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':firebase_messaging:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                         8.9s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.

*******************************************************************************************
Gradle task assembleDebug failed with exit code 1

请将软件包升级到最新版本 firebase_消息:6.0.1。 它会起作用的

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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

// def keystoreProperties = new Properties()
// def keystorePropertiesFile = rootProject.file('key.properties')
// if (keystorePropertiesFile.exists()) {
    // keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
// }

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 28
    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.cantina.user"
        minSdkVersion 16
        multiDexEnabled true
        targetSdkVersion 28
        versionCode 17
        versionName "0.0.5"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }


signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
    }
}
configurations.all {
        resolutionStrategy {
                force 'com.android.support:support-v4:27.1.0'
    }
} 

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}
}

flutter {
    source '../..'
}

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
}

apply plugin: 'com.google.gms.google-services'