首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无事件获取记录的firebase

无事件获取记录的firebase
EN

Stack Overflow用户
提问于 2018-06-30 17:40:08
回答 1查看 377关注 0票数 0

我正在尝试集成Firebase Analytics。然而,问题是,每次我尝试记录事件时,都没有事件报告(即使在通过adb启用调试模式以进行firebase分析之后也是如此)。这在模拟器和我的个人设备上都会发生。每当我记录事件时,我确实看到在logcat中登录时出现错误

工作线程上的虚拟任务异常: com.google.firebase.iid.FirebaseInstanceId.getId()‘:尝试在空对象引用: com.google.android.gms.internal.measurement.zzfc.zzgl(Unknown

:32上调用虚拟方法的java.lang.NullPointerException java.lang.String

我的gradle配置如下

顶级build.gradle

//顶级构建文件,可以添加所有子项目/模块通用的配置选项。

代码语言:javascript
复制
buildscript {

    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-beta02'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath 'io.fabric.tools:gradle:1.+'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

项目的build.gradle

代码语言:javascript
复制
dependencies {
    implementation 'com.google.firebase:firebase-config:16.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    debugImplementation 'com.facebook.stetho:stetho:1.5.0'
    // ViewModel and LiveData
    implementation "android.arch.lifecycle:extensions:1.1.1"
    implementation "android.arch.lifecycle:common-java8:1.1.1"
    implementation "android.arch.persistence.room:runtime:1.1.1"
    implementation "com.google.android.gms:play-services-vision:15.0.2"
    implementation 'joda-time:joda-time:2.10'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
        transitive = true;
    }
    annotationProcessor "android.arch.persistence.room:compiler:1.1.1"

    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    // Paging
    implementation "android.arch.paging:runtime:1.0.0"
    // Test helpers for LiveData
    testImplementation "android.arch.core:core-testing:1.1.1"
    // Test helpers for Room
    testImplementation "android.arch.persistence.room:testing:1.1.1"
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

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

AndroidManifest

代码语言:javascript
复制
<receiver
    android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
    android:enabled="true"
    android:exported="false"/>
<receiver
    android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
    android:enabled="true"
    android:exported="true"
    android:permission="android.permission.INSTALL_PACKAGES">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

<service
    android:name="com.google.android.gms.measurement.AppMeasurementService"
    android:enabled="true"
    android:exported="false" />
<service
    android:name="com.google.android.gms.measurement.AppMeasurementJobService"
    android:enabled="true"
    android:exported="false"
    android:permission="android.permission.BIND_JOB_SERVICE" />

应用程序类

代码语言:javascript
复制
@Override
public void onCreate() {
    super.onCreate();
    FirebaseApp.initializeApp(this);
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
    mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
    mFirebaseAnalytics.setUserId(Utils.fetchDeviceId(this));
    Bundle bundle = new Bundle();
    bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "Test");
    bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Test");
    bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "Test");
    mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
}
EN

回答 1

Stack Overflow用户

发布于 2018-07-01 00:40:15

终于找到了!这是一个明显的合并问题。手动复制服务接收器并开始工作!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51113689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档