error: package com.google.android.gms.ads does not

2019-06-16 03:29发布

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?

3条回答
闹够了就滚
2楼-- · 2019-06-16 04:13

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.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-06-16 04:17

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'
查看更多
神经病院院长
4楼-- · 2019-06-16 04:27

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.

查看更多
登录 后发表回答