java - The following classes could not be instantiated:com.google.android.gms.ads.AdView(Open Class, Show Error Log) -
this xml file
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:ads="http://schemas.android.com/apk/res-auto" android:id="@+id/linearlayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.interadd.mainactivity" > <com.google.android.gms.ads.adview android:id="@+id/adview" android:layout_width="match_parent" android:layout_height="wrap_content" ads:adsize="banner" ads:adunitid="ca-app-pub-2961758853938686/9050318854"/> </linearlayout> this mainfest file
<?xml version="1.0" encoding="utf-8"?> <!doctype xml> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.interadd" 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:minsdkversion="8" android:targetsdkversion="21" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/> <activity android:name=".mainactivity" 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.android.gms.ads.adactivity" android:configchanges="keyboard|keyboardhidden|orientation|screenlayout|uimode|screensize|smallestscreensize"/> </application> </manifest> this java file
package com.example.interadd; import com.google.android.gms.ads.*; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // adview resource , load request. adview adview = (adview)this.findviewbyid(r.id.adview); adrequest adrequest = new adrequest.builder().build(); adview.loadad(adrequest); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } } i fed have tried add ads in app failed have given 100% don't completed project have added google services app give error message following classes not instantiated: - com.google.android.gms.ads.adview (open class, show error log) see error log (window > show view) more details. tried download new eclipse found same error here hope getting project done here thank you
Comments
Post a Comment