0
I did everything as ADMOB site tutorial says, I put the layout in XML, imported the path from Google Play Sevices and added the tutorial code lines, my application compiles, but no longer opens on smartphone, an alerat message appears saying that the app has stopped and in the Eclipse log appears the following message (below), I need a help.
Message in the Eclipse:
05-26 10:47:02.007: E/AndroidRuntime(9092): java.lang.RuntimeException: Unable to start activity ComponentInfo{your.CalculoHE.namespace/your.CalculoHE.namespace.CalculoHoraExtraActivity}: java.lang.NullPointerException
Class:
package your.CalculoHE.namespace;
import org.apache.cordova.DroidGap;
import com.google.android.gms.ads.*;
import android.os.Bundle;
public class CalculoHoraExtraActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
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>
No Math, I’m using the Intel appframework
– Paulo Roberto
I don’t understand the subject, sorry, I’ll pass the ball :)
– Math
Could you inform the Nullpointer line? It’s the line:
adView.loadAd(adRequest);
?– Wakim
@Wakim, is this line even! adView.loadAd(new Adrequest());
– Paulo Roberto
@Wakim appears this error message with the constructor The constructor Adrequest() is Undefined, I don’t know how to solve this!
– Paulo Roberto
Using ANT or Gradle to build the app? This type of message occurs when the class is not in the classpath.
– Wakim
@Pauloroberto does not use the default constructor of
AdRequest
, it is private. Use the Builder...– Wakim
@Wakim I’m using the ANT yes, man I’m already floating in it there, I’m almost giving up... If not following the tutorial of the site the right deal.
– Paulo Roberto
Looking at your code, it’s the same as mine, the problem is in relation to Layout, because it seems that it is not finding Adsview (using findViewById). The problem is in the layout, have to see if Droidgap is not preventing your layout, since you load an html afterwards right...
– Wakim