本文介绍了com.google.ads.AdView:找不到以下类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在我的应用程序中集成admob广告,但出现此错误。
I am trying to integrate admob ads in my application but I am getting this error.
找不到以下类:
-com.google.ads.AdView
"The following classes could not be found:- com.google.ads.AdView "
主要XML布局代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/background" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="My_Add_Id"
ads:loadAdOnCreate="true" />
维护文件如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.solutionproviders.bajiascooking"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-sdk android:targetSdkVersion="16"
android:minSdkVersion="9"/>
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Main"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
我正在使用Google Play服务添加广告。
I am using Google play services for adding ads.
我已检查了所有解决方案提供了Stakeoverflow,但没有一个对我有用。请给我建议一个解决方案。将提供任何其他信息,但我想我已经为问题提供了足够的信息。
I am checked all the solutions provided on Stakeoverflow but none worked for me. Please suggest me a solution. Any other info will be provided but I think I have provided enough info for the problem.
推荐答案
只需遵循以下3个步骤:
Just follow these 3 steps:
- 在gradle应用程序级别添加依赖项。
- 在yourfile.xml中添加xml
- onCreate方法中的Java代码
依赖项:
实现'com.google.android.gms:play-services-ads:11.8.0'
这篇关于com.google.ads.AdView:找不到以下类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!