错误:包 com.google.android.gms.ads 不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20403136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:48:08  来源:igfitidea点击:

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

androidimportnetbeans-7.4

提问by user3070657

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:

我的 Android 应用运行良好(API 15),直到我想包含 Google 广告。虽然 google-play-services.jar 在我的项目库中并且它包含 com.google.android.gms.ads,但调试器出现错误:使用时包 com.google.android.gms.ads 不存在:

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?

我尝试了几种解决方案,但都没有奏效。我从 Android 4.03 API15 更改为 Google API15,但没有任何改变。我究竟做错了什么?

回答by gahfy

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_liband declare it as library of your project.

您必须导入位于文件夹中的 google-play-services_lib<android-sdk-directory>/extras/google/google_play_services/libproject/google-play-services_lib并将其声明为您的项目库。

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

您将找到有关设置 Google Play 服务 SDK 的更多信息。

回答by abc

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

在gradle中添加标记的行

Add the following code in the gradle.

在gradle中添加以下代码。

    implementation 'com.google.android.gms:play-services-ads:11.8.0'

回答by Jeremy Quick

I had this problem when building an ionic cordova project after adding the plugin admob-google-cordovaand 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.

在添加插件admob-google-cordova并运行ionic cordova build. 对我来说,我走进了我的project.propertiesplatforms/android/project.properties)文件,并从改了行cordova.system.library.1=com.google.android.gms:play-services-ads:+cordova.system.library.1=com.google.android.gms:play-services-ads:9.8.0