Android Studio amp; AdMob -- The following classes could not be instantiated(安卓工作室AdMob -- 无法实例化以下类)
问题描述
我一直在尝试在我的应用中使用 AdMob 横幅广告,但一直收到错误消息;
I have been trying to use an AdMob banner ad in my app but keep getting the error;
无法实例化以下类:- com.google.android.gms.ads.AdView
The following classes could not be instantiated: - com.google.android.gms.ads.AdView
我已经尝试了在这里和谷歌搜索可以找到的所有解决方案.我有;
I have tried every solution I can find on here and by Googling. I have;
在我的毕业典礼上.我已经输入了这里指定的所有部分;
in my gradle. I have entered all the parts specified here;
https://developers.google.com/mobile-ads-sdk/docs/
但还是一无所获.希望有人能帮忙..!
But still nothing. Hope someone can help..!
干杯
activity_main.xml
activity_main.xml
AndroidManifest.xml
AndroidManifest.xml
build.gradle(依赖)
build.gradle (dependencies)
推荐答案
我在尝试预览自定义视图 AdView 时遇到了同样的问题.我的项目是通过 Intellij 社区版 (13.x) 使用 gradle 构建的,我最终将 google play 服务的版本从
I had the same problem when trying to preview the custom view AdView. My project is built using gradle via Intellij community edition (13.x) and I ended up changing the version of google play services from
到
具体来说,我将 gradle 文件的依赖项部分更改为如下所示:
specifically, I changed the dependencies section of my gradle file to look like this:
这篇关于安卓工作室AdMob -- 无法实例化以下类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!