Firebase消息传递服务应在哪个架构层中运行。应该是数据层

时间:2018-12-16 10:57:28

标签: android firebase firebase-cloud-messaging

Android Studio 3.4 Canary 8

我正在创建一个使用Firebase消息传递服务的应用程序。我的体系结构具有表示层,域和数据层。

通常,我将Firebase消息传递服务放在数据层中,以为它应该在此处。但是,我可以使用它,因为在尝试同步数据build.gradle文件时它会崩溃。

我的数据层build.gradle我有以下内容:

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    def androidConfig = rootProject.extensions.getByName("ext")

    compileSdkVersion = androidConfig["androidCompileSdkVersion"]

    defaultConfig {
        minSdkVersion androidConfig["androidMinSdkVersion"]
    }

    sourceSets {
        main {
            manifest.srcFile 'src/main/AndroidManifest.xml'
        }
    }
}

dependencies {
    def dataDependencies = rootProject.ext.dataDependencies
    def dataTestDependencies = rootProject.ext.dataTestDependencies

    implementation dataDependencies.rxjava
    implementation dataDependencies.rxkotlin
    implementation dataDependencies.gson
    implementation dataDependencies.retrofit
    implementation dataDependencies.firebaseCore
    implementation dataDependencies.firebaseMessaging
    implementation dataDependencies.kotlin

    testImplementation dataTestDependencies.robolectric

    implementation project(':domain')
}

sourceCompatibility = "1.6"
targetCompatibility = "1.6"

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

但是,当我同步项目时,它失败并显示以下有关空指针异常的消息。仅当我添加com.google.gms.google-services插件

时,
A problem occurred configuring project ':data'.
> java.lang.NullPointerException

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':data'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:79)
    at 
Caused by: java.lang.NullPointerException

我的数据层android清单是:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="me.androidbox.data">

    <application>
        <service android:name=".firebaseservice.Messaging">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

    </application>
</manifest>

0 个答案:

没有答案
相关问题