无法调用跟踪代码管理器的Android JAVA

时间:2019-08-09 17:03:57

标签: java android firebase google-tag-manager android-studio-3.0

我正在尝试通过Firebase实施谷歌标签管理器。我已经成功地将事件放回了Firebase,但是当我尝试将数据发送到Google跟踪代码管理器时,确实出现了错误:

Failed to invoke Tag Manager's initialize()。 关于logcat的更多详细信息:

2019-08-09 23:56:40.847 2817-2857/? I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2019-08-09 23:56:41.024 2817-2857/? I/e.myapplicatio: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.tagmanager.zzco>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzee;
2019-08-09 23:56:41.024 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.zzbf.zzbo(android.content.Context) ((null):-1)
2019-08-09 23:56:41.024 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.TagManagerService.initialize(android.content.Context) ((null):-1)
2019-08-09 23:56:41.024 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.zzbf.zzbo(android.content.Context) ((null):-1)
2019-08-09 23:56:41.024 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.TagManagerService.initialize(android.content.Context) ((null):-1)
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.tagmanager.zzbg>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/tagmanager/zzco;
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.zzbf.zzbo(android.content.Context) ((null):-1)
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.TagManagerService.initialize(android.content.Context) ((null):-1)
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio: Caused by: java.lang.ClassNotFoundException: com.google.android.gms.tagmanager.zzco
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.zzbf.zzbo(android.content.Context) ((null):-1)
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.TagManagerService.initialize(android.content.Context) ((null):-1)
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.tagmanager.zzbg>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/tagmanager/zzco;
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.zzbf.zzbo(android.content.Context) ((null):-1)
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.TagManagerService.initialize(android.content.Context) ((null):-1)
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio: Caused by: java.lang.ClassNotFoundException: com.google.android.gms.tagmanager.zzco
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.zzbf.zzbo(android.content.Context) ((null):-1)
2019-08-09 23:56:41.025 2817-2857/? I/e.myapplicatio:     at void com.google.android.gms.tagmanager.TagManagerService.initialize(android.content.Context) ((null):-1)
2019-08-09 23:56:41.028 2817-2857/? W/FA: Failed to invoke Tag Manager's initialize() method: java.lang.reflect.InvocationTargetException: com.google.android.gms.measurement.internal.zzgp.zza(Unknown Source:121)

这是我对应用程序build.gradle的依赖

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.android.gms:play-services-tagmanager:11.0.4'
}
apply plugin: 'com.google.gms.google-services'
// Work around
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

这是在root build.gradle上

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

如果你们对如何解决这个问题有任何了解

1 个答案:

答案 0 :(得分:0)

我通过将google标记管理器依赖项升级到此版本找到了解决方案

implementation 'com.google.android.gms:play-services-tagmanager:16.0.8'

代替此

implementation 'com.google.android.gms:play-services-tagmanager:11.0.4'

现在的问题是,firebase建议在其文档上使用11.0.4版本。他们可能需要改变这一点 链接到文档: https://developers.google.com/tag-manager/android/v5/