添加firebase_messaging依赖项时Android挂起安装app.apk

时间:2019-09-30 23:09:08

标签: android firebase intellij-idea flutter firebase-cloud-messaging

我想在Flutter应用程序中使用Firebase消息传递(以及其他Firebase功能)。我已经在为Android安装firestore时遇到了很多麻烦(firebase教程在ios上运行良好),但是现在当我尝试添加消息传递依赖项时,我遇到了一个新的(甚至更加不透明的)错误:当我运行调用flutter get packages的android模拟器后,我收到以下消息:

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)

最后,这是我的Google服务版本(在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"
    }

有人知道为什么会发生这种挂起以及如何解决它吗?预先感谢!

1 个答案:

答案 0 :(得分:0)

android\build.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