Reputation: 41
I have created an Android App for testing admob ads but when I run it, it force closes. My MainActivity:-
package com.dibdev.bmicalculator;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class BMI_Calculator extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bmi__calculator);
}}
My Manifest. I do not think there is any error here.... :-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dibdev.bmicalculator"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity
android:name=".BMI_Calculator"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
</activity>
</application>
My Layout File. I have included xmlns...... in com.google...... Is it correct?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
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.dibdev.bmicalculator.BMI_Calculator" >
<com.google.android.gms.ads.AdView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="SAMPLE"
ads:startOnCreate="True" >
</com.google.android.gms.ads.AdView>
My Logcat :-
11-08 14:37:58.161: I/System.out(25610): Sending WAIT chunk
11-08 14:37:58.161: W/ActivityThread(25610): Application com.dibdev.bmicalculator is waiting for the debugger on port 8100...
11-08 14:37:58.176: I/dalvikvm(25610): Debugger is active
11-08 14:37:58.361: I/System.out(25610): Debugger has connected
11-08 14:37:58.456: I/System.out(25610): waiting for debugger to settle...
11-08 14:37:58.656: I/System.out(25610): waiting for debugger to settle...
11-08 14:37:58.856: I/System.out(25610): waiting for debugger to settle...
11-08 14:37:59.056: I/System.out(25610): waiting for debugger to settle...
11-08 14:37:59.256: I/System.out(25610): waiting for debugger to settle...
11-08 14:37:59.456: I/System.out(25610): waiting for debugger to settle...
11-08 14:37:59.661: I/System.out(25610): debugger has settled (1310)
11-08 14:37:59.681: E/dalvikvm(25610): dvmPauseGc(AppLaunch) called - cookie=0x47d7 (f=0x1)
11-08 14:37:59.691: I/PersonaManager(25610): getPersonaService() name persona_policy
11-08 14:37:59.741: D/skia(25610): GFXPNG PNG bitmap created width:48 height:48 bitmap id is 180
11-08 14:37:59.751: D/skia(25610): GFXPNG PNG bitmap created width:72 height:72 bitmap id is 181
11-08 14:37:59.766: D/skia(25610): GFXPNG PNG bitmap created width:72 height:72 bitmap id is 182
11-08 14:37:59.781: D/skia(25610): GFXPNG PNG bitmap created width:13 height:41 bitmap id is 183
11-08 14:37:59.786: D/skia(25610): GFXPNG PNG bitmap created width:18 height:18 bitmap id is 184
11-08 14:37:59.791: D/skia(25610): GFXPNG PNG bitmap created width:18 height:18 bitmap id is 185
11-08 14:37:59.801: D/skia(25610): GFXPNG PNG bitmap created width:18 height:18 bitmap id is 186
11-08 14:37:59.836: E/MoreInfoHPW_ViewGroup(25610): Parent view is not a TextView
11-08 14:37:59.861: D/skia(25610): GFXPNG PNG bitmap created width:72 height:72 bitmap id is 187
11-08 14:37:59.871: D/skia(25610): GFXPNG PNG bitmap created width:72 height:72 bitmap id is 188
11-08 14:37:59.881: D/skia(25610): GFXPNG PNG bitmap created width:72 height:72 bitmap id is 189
11-08 14:37:59.911: W/dalvikvm(25610): VFY: unable to resolve static field 1355 (AdsAttrs) in Lcom/google/android/gms/R$styleable;
11-08 14:37:59.911: D/dalvikvm(25610): VFY: replacing opcode 0x62 at 0x0009
11-08 14:37:59.916: I/dalvikvm(25610): DexOpt: unable to optimize static field ref 0x054c at 0x0f in Lcom/google/android/gms/internal/bb;.<init>
11-08 14:37:59.916: I/dalvikvm(25610): DexOpt: unable to optimize static field ref 0x054d at 0x15 in Lcom/google/android/gms/internal/bb;.<init>
11-08 14:37:59.921: I/dalvikvm(25610): DexOpt: unable to optimize static field ref 0x054e at 0x32 in Lcom/google/android/gms/internal/bb;.<init>
11-08 14:38:00.911: D/dalvikvm(25610): threadid=1: still suspended after undo (sc=1 dc=1)
Upvotes: 0
Views: 247
Reputation: 2088
in latest ads sdk you need to add meta tag for gms version with ad declaration in menifest file which you forget to add.
integer value can be differ form your value, you can get it in your log cat while debunging.
<meta-data
android:name="com.google.android.gms.version"
android:value="6111000" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
Upvotes: 0
Reputation: 734
I think you missed the activity closing tag of BMI_Calculator activity in your manifest. If that's not it, please post the stacktrace.
Upvotes: 1