Android : adView.loadAd() crashing android app

on Sunday, July 6, 2014


I am trying to get the Google play services ads set up on my app. However whenever I attempt the call the



adView.loadAd()


it crashes the app. If I comment out this line the ad doesn't crash but the window doesn't show up. I've tried looking at similar questions about this topic but couldn't find a solution that would work for me. Any help would be greatly appreciated.


this is from my main:



protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView1);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest); // this is what seems to be causing the problem


manifest:



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.williampatrickweld2.deckofcardsworkoutfree"
android:versionCode="3"
android:versionName="1.2" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />

<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:resizeable="true"
/>
<application

android:allowBackup="true"
android:icon="@raw/docmedium"
android:label="@string/app_name"
android:theme="@style/AppThemeNoTitleBar" >
<activity

android:name="com.williampatrickweld2.deckofcardsworkoutfree.MainActivity"
android:screenOrientation="portrait"
android:label="@string/app_name">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<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|s mallestScreenSize"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

</manifest>


logcat:



07-06 20:42:36.593: I/Process(21454): Sending signal. PID: 21454 SIG: 9
07-06 20:42:52.420: D/skia(21817): ---- fAsset->read(2450) returned 0
07-06 20:42:52.570: D/AndroidRuntime(21817): Shutting down VM
07-06 20:42:52.570: W/dalvikvm(21817): threadid=1: thread exiting with uncaught exception (group=0x41815da0)
07-06 20:42:52.570: E/AndroidRuntime(21817): FATAL EXCEPTION: main
07-06 20:42:52.570: E/AndroidRuntime(21817): Process: c com.williampatrickweld2.deckofcardsworkoutfree, PID: 21817
07-06 20:42:52.570: E/AndroidRuntime(21817): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.williampatrickweld2.deckofcardsworkoutfree/com.williampatrickweld2.deckof cardsworkoutfree.MainActivity}: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2334)
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.app.ActivityThread.access$900(ActivityThread.java:169)
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.os.Handler.dispatchMessage(Handler.java:102)
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.os.Looper.loop(Looper.java:146)
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.app.ActivityThread.main(ActivityThread.java:5487)
07-06 20:42:52.570: E/AndroidRuntime(21817): at java.lang.reflect.Method.invokeNative(Native Method)
07-06 20:42:52.570: E/AndroidRuntime(21817): at java.lang.reflect.Method.invoke(Method.java:515)
07-06 20:42:52.570: E/AndroidRuntime(21817): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
07-06 20:42:52.570: E/AndroidRuntime(21817): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
07-06 20:42:52.570: E/AndroidRuntime(21817): at dalvik.system.NativeStart.main(Native Method)
07-06 20:42:52.570: E/AndroidRuntime(21817): Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
07-06 20:42:52.570: E/AndroidRuntime(21817): at com.google.android.gms.common.GooglePlayServicesUtil.x(Unknown Source)
07-06 20:42:52.570: E/AndroidRuntime(21817): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
07-06 20:42:52.570: E/AndroidRuntime(21817): at com.google.android.gms.internal.ai.a(Unknown Source)
07-06 20:42:52.570: E/AndroidRuntime(21817): at com.google.android.gms.internal.av.aH(Unknown Source)
07-06 20:42:52.570: E/AndroidRuntime(21817): at com.google.android.gms.internal.av.a(Unknown Source)
07-06 20:42:52.570: E/AndroidRuntime(21817): at com.google.android.gms.ads.AdView.loadAd(Unknown Source)
07-06 20:42:52.570: E/AndroidRuntime(21817): at com.williampatrickweld2.deckofcardsworkoutfree.MainActivity.onCreate(MainActivity.java:70)
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.app.Activity.performCreate(Activity.java:5451)
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
07-06 20:42:52.570: E/AndroidRuntime(21817): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
07-06 20:42:52.570: E/AndroidRuntime(21817): ... 11 more
07-06 20:42:54.712: I/Process(21817): Sending signal. PID: 21817 SIG: 9

0 comments:

Post a Comment