我想在我的颤振应用中使用 Firebase 消息传递(以及其他 Firebase 功能(。我已经在安装适用于 android 的 firestore 时遇到了很多麻烦(Firebase 教程在 iOS 上运行良好(,但现在当我尝试添加消息传递依赖项时,我收到一个新的(甚至更不透明(错误:当我在调用 android 后运行 android 模拟器时flutter get packages
,我收到以下消息:
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...
然后程序就挂起了。该应用程序没有完成构建,我无法在模拟设备上打开它,并且程序似乎没有任何进展(我尝试将其放置 15 分钟左右,但无济于事(。当我排除firebase_messaging: ^5.1.6
依赖项时,不会发生这种情况。
这是我的 .yaml 文件的依赖项部分:
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.12.9+4
firebase_storage: ^3.0.6
firebase_core: ^0.4.0+9
firebase_messaging: ^5.1.6 //this is the problematic line
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
以下是有关我的设置的一些信息:
[✓] Flutter (Channel beta, v1.9.1+hotfix.4, on Mac OS X, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.3)
[✓] Connected device (2 available)
最后,这是我的谷歌服务版本(在android/build.gradle中(
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.gms:google-services:3.2.1"
}
有谁知道为什么会发生这种挂起以及如何解决它?提前感谢!
androidbuild.gradle
确保您有:
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.3.2'
}
在gradle-wrapper.properties
请确保您有:distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
最后:运行flutter upgrade
只是为了确保运行也flutter clean