10

My Android app did work well (API 15) untill I wanted to include Google ads. Although google-play-services.jar is in my project library and it contains com.google.android.gms.ads, the debugger comes up with an error: package com.google.android.gms.ads does not exist when using:

import com.google.android.gms.ads.*;

I tried several solutions, but none of them worked. I changed from Android 4.03 API15 to Google API15 but nothing changed. What am I doing wrong?

user3070657
  • 101
  • 1
  • 1
  • 3
  • If anybody is getting this error with cordova when running `ant release` and it's 2015 or later, this issue might help: https://github.com/floatinghotpot/cordova-admob-pro/issues/179 – Sarah Jan 21 '16 at 01:18

3 Answers3

4

There might be several years have been already gone but no good solution. So, someone like me facing the same trouble till today. I have solved it by the following method (check the attached figure)-

Add the marked line in the gradle

Add the following code in the gradle.

    implementation 'com.google.android.gms:play-services-ads:11.8.0'
abc
  • 275
  • 3
  • 11
3

You must import google-play-services_lib that is located in the folder <android-sdk-directory>/extras/google/google_play_services/libproject/google-play-services_lib and declare it as library of your project.

You will find more informations on Set Up Google Play Services SDK.

  • how to import "google-play-services_lib" ???? lots of confusing google links in the net.. and that link "Set Up Google Play Services SDK", does not teach this... – Camila Yamamoto Sep 17 '18 at 09:20
2

I had this problem when building an ionic cordova project after adding the plugin admob-google-cordova and running ionic cordova build. For me I went into my project.properties (platforms/android/project.properties) file and changed the line from cordova.system.library.1=com.google.android.gms:play-services-ads:+ into cordova.system.library.1=com.google.android.gms:play-services-ads:9.8.0.

Jeremy
  • 3,620
  • 9
  • 43
  • 75