首页 > 解决方案 > 带有 Tealium AdIdentifier 插件的 Cordova 应用程序在 Android 设备上启动时崩溃

问题描述

按照https://docs.tealium.com/platforms/cordova/install/https://docs.tealium.com/platforms/cordova/module-adid/上的安装说明,我的应用程序在启动时崩溃。

错误信息是:

com.tealium.adidentifier.AdIdentifier$1.run

java.lang.ClassNotFoundException: Didn't find class 
"com.google.android.gms.ads.identifier.AdvertisingIdClient" on path: 
DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file 
"/data/app/tv.talpa.vi.nld.test-
2s3C4hjESlp1c4kXXrJEoA==/base.apk"],nativeLibraryDirectories=
[/data/app/tv.talpa.vi.nld.test-2s3C4hjESlp1c4kXXrJEoA==/lib/arm64, /system/lib64, 
/vendor/lib64]]

使用 Cordova Android 8.0.0。

知道这里出了什么问题吗?

标签: androidcordovagoogle-play-services

解决方案


通过强制在 Gradle 构建配置中添加 Google Play 服务来解决此问题:

allprojects {
  repositories {
    jcenter()
    maven { url 'https://maven.google.com' }
  }
}

buildscript {
  repositories {
    mavenCentral()
    jcenter()
  }
}
configurations.all {
  resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  }

  resolutionStrategy {
    force 'com.google.android.gms:play-services-gcm:16.1.0'
  }
}

还用 Tealium 标记了这个: https ://github.com/Tealium/cordova-plugin/issues/37#issuecomment-508789280


推荐阅读