Ich bin wirklich verzweifelt jetzt, ich versuchte alles.AdMob Force schließen (Android)
Jedes Mal, wenn ich meine App ausführen, wird diese Kraft geschlossen. Es zeigt dies im Logcat.
04-02 21:26:33.079: E/AndroidRuntime(18013): FATAL EXCEPTION: main
04-02 21:26:33.079: E/AndroidRuntime(18013): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pxr.tutorial.xmltest/com.pxr.tutorial.xmltest.Main}: java.lang.NullPointerException
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.os.Looper.loop(Looper.java:137)
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-02 21:26:33.079: E/AndroidRuntime(18013): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 21:26:33.079: E/AndroidRuntime(18013): at java.lang.reflect.Method.invoke(Method.java:511)
04-02 21:26:33.079: E/AndroidRuntime(18013): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
04-02 21:26:33.079: E/AndroidRuntime(18013): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
04-02 21:26:33.079: E/AndroidRuntime(18013): at dalvik.system.NativeStart.main(Native Method)
04-02 21:26:33.079: E/AndroidRuntime(18013): Caused by: java.lang.NullPointerException
04-02 21:26:33.079: E/AndroidRuntime(18013): at com.pxr.tutorial.xmltest.Main.onCreate(Main.java:41)
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.app.Activity.performCreate(Activity.java:4465)
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-02 21:26:33.079: E/AndroidRuntime(18013): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-02 21:26:33.079: E/AndroidRuntime(18013): ... 11 more
Main.java
public class Main extends ListActivity {
private AdView adView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listplaceholder);
LinearLayout layout = (LinearLayout)findViewById(R.layout.main);
adView = new AdView(this, AdSize.BANNER, "here i put my id with the quotes");
layout.addView(adView);
AdRequest adRequest = new AdRequest();
adRequest.setTesting(true);
adView.loadAd(adRequest);
Manifest:
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
listplaceholder.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawSelectorOnTop="false" />
<TextView
android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="No data"/>
</LinearLayout>
Ja, ich habe die Bibliotheken importiert und das Build-Ziel geändert. Ich änderte auch lib zu libs.
Bitte helfen Sie mir :(
Welches ist Zeile 41 Ihrer Hauptklassendatei? –
layout.addView (adView); – Niell
Ich habe die Datei listplaceholder.xml meinem Beitrag hinzugefügt. – Niell