我在火力基础消息传递包工作时遇到问题,出现以下错误。我已经尝试了所有发布的解决方案。我尝试过颤振干净,将最小 sdk 升级到 28 并遵守一个,但这不起作用
但是没有任何效果,我希望在这方面寻求帮助,浪费了一天的开发时间。 谢谢
E:flutterflutter.pub-cachehostedpub.dartlang.orgfirebase_messaging-2.2.0+1androidsrcmainjavaioflutterpluginsfirebasemessagingFirebaseMessagingPlugin.java:12: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
E:flutterflutter.pub-cachehostedpub.dartlang.orgfirebase_messaging-2.2.0+1androidsrcmainjavaioflutterpluginsfirebasemessagingFirebaseMessagingPlugin.java:13: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
^
E:flutterflutter.pub-cachehostedpub.dartlang.orgfirebase_messaging-2.2.0+1androidsrcmainjavaioflutterpluginsfirebasemessagingFlutterFirebaseInstanceIDService.java:9: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
^
^
E:flutterflutter.pub-cachehostedpub.dartlang.orgfirebase_messaging-2.2.0+1androidsrcmainjavaioflutterpluginsfirebasemessagingFirebaseMessagingPlugin.java:81: error: cannot find symbol
@NonNull
^
symbol: class NonNull
location: class FirebaseMessagingPlugin
E:flutterflutter.pub-cachehostedpub.dartlang.orgfirebase_messaging-2.2.0+1androidsrcmainjavaioflutterpluginsfirebasemessagingFirebaseMessagingPlugin.java:57: error: cannot find symbol
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(registrar.context());
^
symbol: class LocalBroadcastManager
location: class FirebaseMessagingPlugin
E:flutterflutter.pub-cachehostedpub.dartlang.orgfirebase_messaging-2.2.0+1androidsrcmainjavaioflutterpluginsfirebasemessagingFirebaseMessagingPlugin.java:57: error: cannot find symbol
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(registrar.context());
^
symbol: variable LocalBroadcastManager
location: class FirebaseMessagingPlugin
E:flutterflutter.pub-cachehostedpub.dartlang.orgfirebase_messaging-2.2.0+1androidsrcmainjavaioflutterpluginsfirebasemessagingFirebaseMessagingPlugin.java:122: error: cannot find symbol
public void onComplete(@NonNull Task<InstanceIdResult> task) {
^
);
^
symbol: variable LocalBroadcastManager
location: class FlutterFirebaseInstanceIDService
E:flutterflutter.pub-cachehostedpub.dartlang.orgfirebase_messaging-2.2.0+1androidsrcmainjavaioflutterpluginsfirebasemessagingFlutterFirebaseMessagingService.java:27: error: cannot find symbol
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
^
symbol: variable LocalBroadcastManager
location: class FlutterFirebaseMessagingService
Note: E:flutterflutter.pub-cachehostedpub.dartlang.orgfirebase_messaging-2.2.0+1androidsrcmainjavaioflutterpluginsfirebasemessagingFlutterFirebaseInstanceIDService.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
在这里你可以找到我的build.gradle/app
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'
请将您的软件包升级到最新版本firebase_messaging:6.0.1.它会工作