没有找到"com.google.android.gms.ads.identifier.AdvertisingIdClient"类

use*_*225 3 android maven google-play google-play-services google-advertising-id

我正在使用Maven来构建我的android项目.在我的Android项目pom.xml中,我已经定义了google-play-service的依赖关系:

<dependency>
  <groupId>com.google.android.gms</groupId>
  <artifactId>google-play-services</artifactId>
  <type>apklib</type>
  <version>7</version>
  <scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我的项目成功建成.我正在使用的Android设备也安装了Google Play应用.但是,当我启动我的应用程序时,我不断收到以下错误:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.identifier.AdvertisingIdClient" on path: DexPathList[[zip file "/data/app/com.my.app-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
Run Code Online (Sandbox Code Playgroud)

这个错误的原因是什么?怎么解决?

Jar*_*ows 6

我会强烈建议使用GradleMaven.

但是,请确保使用正确的导入:

com.google.android.gms:play-services-ads:7.5.0

更新ArtifactIDVersion:

<dependency>
  <groupId>com.google.android.gms</groupId>
  <artifactId>play-services-ads</artifactId>
  <version>7.5.0</version>
  <type>apklib</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)

文档:https://developers.google.com/android/guides/setup