I did everything as the tutorial of the ADMOB website, I placed the layout in the XML, imported the path of Google Play Sevices and added the lines of code of the tutorial, my application compiles but does not open on the smartphone, a message appears of alerat saying that the app stopped and in the Eclipse log the following message appears (below), I need a help.
MessageinEclipse:
05-2610:47:02.007:E/AndroidRuntime(9092):java.lang.RuntimeException:UnabletostartactivityComponentInfo{your.CalculoHE.namespace/your.CalculoHE.namespace.CalculoHoraExtraActivity}:java.lang.NullPointerException
Class:
packageyour.CalculoHE.namespace;importorg.apache.cordova.DroidGap;importcom.google.android.gms.ads.*;importandroid.os.Bundle;publicclassCalculoHoraExtraActivityextendsDroidGap{/**Calledwhentheactivityisfirstcreated.*/@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);super.setContentView(R.layout.main);super.setIntegerProperty("splashscreen", R.drawable.sobreaviso);
super.loadUrl("file:///android_asset/www/index.html", 3000);
// Consultar o AdView como um recurso e carregar uma solicitação.
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="ca-app-pub-6560993155721972/3382486845"
ads:adSize="BANNER"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hora extras"
/>
</LinearLayout>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.CalculoHE.namespace"
android:versionCode="4"
android:versionName="1.2" >
<uses-sdk android:minSdkVersion="9" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<application android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity android:configChanges="orientation|keyboardHidden" android:name=".CalculoHoraExtraActivity"
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|screenSize"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>