Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Didn't find class "com.google.android.gms.ads.identifier.AdvertisingIdClient"

I am using Maven to build my android project. In my Android project pom.xml, I have defined the dependency of 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>

My project was built successfully. The android device I am using also has Google Play app installed. But when I start my app, I constantly get the following error:

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)

What could be the reason for this error? How to fix it?

like image 251
user842225 Avatar asked Feb 09 '23 09:02

user842225


1 Answers

I would highly suggest using Gradle over Maven.

However, make sure you using the correct import:

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

Updated ArtifactID and Version:

<dependency>
  <groupId>com.google.android.gms</groupId>
  <artifactId>play-services-ads</artifactId>
  <version>7.5.0</version>
  <type>apklib</type>
</dependency>

Docs: https://developers.google.com/android/guides/setup

like image 67
Jared Burrows Avatar answered Feb 12 '23 10:02

Jared Burrows