0
我想在我的android sdk應用程序中添加admob。我正在關注該鏈接:https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start我該如何在我的android sdk xml中使用谷歌廣告羣
我不知道爲什麼或者如何解決這個錯誤。我不知道我錯過了什麼。
堆棧:
09-02 00:49:15.040: E/AndroidRuntime(754): FATAL EXCEPTION: main
09-02 00:49:15.040: E/AndroidRuntime(754): Process: com.example.pingpong, PID: 754
09-02 00:49:15.040: E/AndroidRuntime(754): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pingpong/com.a.pingpong.mainMenu}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
09-02 00:49:15.040: E/AndroidRuntime(754): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.app.ActivityThread.access$800(ActivityThread.java:138)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.os.Handler.dispatchMessage(Handler.java:102)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.os.Looper.loop(Looper.java:136)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.app.ActivityThread.main(ActivityThread.java:5026)
09-02 00:49:15.040: E/AndroidRuntime(754): at java.lang.reflect.Method.invokeNative(Native Method)
09-02 00:49:15.040: E/AndroidRuntime(754): at java.lang.reflect.Method.invoke(Method.java:515)
09-02 00:49:15.040: E/AndroidRuntime(754): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
09-02 00:49:15.040: E/AndroidRuntime(754): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
09-02 00:49:15.040: E/AndroidRuntime(754): at dalvik.system.NativeStart.main(Native Method)
09-02 00:49:15.040: E/AndroidRuntime(754): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
09-02 00:49:15.040: E/AndroidRuntime(754): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
09-02 00:49:15.040: E/AndroidRuntime(754): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
09-02 00:49:15.040: E/AndroidRuntime(754): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
09-02 00:49:15.040: E/AndroidRuntime(754): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.app.Activity.setContentView(Activity.java:1930)
09-02 00:49:15.040: E/AndroidRuntime(754): at com.a.pingpong.mainMenu.onCreate(mainMenu.java:23)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.app.Activity.performCreate(Activity.java:5242)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-02 00:49:15.040: E/AndroidRuntime(754): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
09-02 00:49:15.040: E/AndroidRuntime(754): ... 11 more
09-02 00:52:59.490: D/AndroidRuntime(804): Shutting down VM
09-02 00:52:59.490: W/dalvikvm(804): threadid=1: thread exiting with uncaught exception (group=0xb3a8bd70)
09-02 00:52:59.510: E/AndroidRuntime(804): FATAL EXCEPTION: main
09-02 00:52:59.510: E/AndroidRuntime(804): Process: com.example.pingpong, PID: 804
09-02 00:52:59.510: E/AndroidRuntime(804): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pingpong/com.a.pingpong.mainMenu}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
09-02 00:52:59.510: E/AndroidRuntime(804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.app.ActivityThread.access$800(ActivityThread.java:138)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.os.Handler.dispatchMessage(Handler.java:102)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.os.Looper.loop(Looper.java:136)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.app.ActivityThread.main(ActivityThread.java:5026)
09-02 00:52:59.510: E/AndroidRuntime(804): at java.lang.reflect.Method.invokeNative(Native Method)
09-02 00:52:59.510: E/AndroidRuntime(804): at java.lang.reflect.Method.invoke(Method.java:515)
09-02 00:52:59.510: E/AndroidRuntime(804): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
09-02 00:52:59.510: E/AndroidRuntime(804): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
09-02 00:52:59.510: E/AndroidRuntime(804): at dalvik.system.NativeStart.main(Native Method)
09-02 00:52:59.510: E/AndroidRuntime(804): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
09-02 00:52:59.510: E/AndroidRuntime(804): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
09-02 00:52:59.510: E/AndroidRuntime(804): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
09-02 00:52:59.510: E/AndroidRuntime(804): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
09-02 00:52:59.510: E/AndroidRuntime(804): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.app.Activity.setContentView(Activity.java:1930)
09-02 00:52:59.510: E/AndroidRuntime(804): at com.a.pingpong.mainMenu.onCreate(mainMenu.java:23)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.app.Activity.performCreate(Activity.java:5242)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-02 00:52:59.510: E/AndroidRuntime(804): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
09-02 00:52:59.510: E/AndroidRuntime(804): ... 11 more
AndroidManifest.xml中
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
...
<application
....
>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
.......
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
layout.xml
<LinearLayout
...
xmlns:ads = "http://schemas.android.com/apk/lib/com.google.ads"
....
>
<com.google.android.gsm.ads.AdView
android:id = "@+id/adView"
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
ads:adUnitId = "ea-eap-vav-1123185352332330/2222333344"
ads:adSize = "BANNER"
ads:testDevices = "TEST_EMULATOR, samsung-samsung_si_f910e-awc34ed0"
ads:loadAdOnCreate = "true" />
mainMenu.java
protected void onCreate(Bundle savedInstanceState) {
....
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}