i have tried adding the com.google.ads.AdView to the xml part, xml coding as follows:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_color"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="5dp"
android:stretchColumns="*" >
<TableRow
<Button android:id="@+id/equal"
style="@style/Eq_button_style"
android:text="=">
</Button>
</TableRow>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a123123123123c" //this ID is confirmed correct
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, xxxxxxxxxxxxxxxxx" //this ID is confirmed correct
ads:loadAdOnCreate="true"/>
</TableLayout>
However, even though the app does not crash when it runs, there is no ads showing at the bottom. the logcat is as follows:
10-10 01:45:16.360: I/GATE(16797): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
10-10 01:45:16.365: D/webviewglue(16797): nativeDestroy view: 0x3ef6f0
10-10 01:45:16.365: E/Ads(16797): An error occurred while destroying an AdWebView:
10-10 01:45:16.365: E/Ads(16797): java.lang.NullPointerException
10-10 01:45:16.365: E/Ads(16797): at android.webkit.WebView.setWebViewClient(WebView.java:5168)
10-10 01:45:16.365: E/Ads(16797): at com.google.ads.internal.AdWebView.destroy(SourceFile:252)
10-10 01:45:16.365: E/Ads(16797): at com.google.ads.internal.c$e.run(SourceFile:191)
10-10 01:45:16.365: E/Ads(16797): at android.os.Handler.handleCallback(Handler.java:605)
10-10 01:45:16.365: E/Ads(16797): at android.os.Handler.dispatchMessage(Handler.java:92)
10-10 01:45:16.365: E/Ads(16797): at android.os.Looper.loop(Looper.java:137)
10-10 01:45:16.365: E/Ads(16797): at android.app.ActivityThread.main(ActivityThread.java:4511)
10-10 01:45:16.365: E/Ads(16797): at java.lang.reflect.Method.invokeNative(Native Method)
10-10 01:45:16.365: E/Ads(16797): at java.lang.reflect.Method.invoke(Method.java:511)
10-10 01:45:16.365: E/Ads(16797): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
10-10 01:45:16.365: E/Ads(16797): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
10-10 01:45:16.365: E/Ads(16797): at dalvik.system.NativeStart.main(Native Method)
10-10 01:45:16.365: I/Ads(16797): onReceiveAd()
10-10 01:45:16.460: D/dalvikvm(16797): GC_CONCURRENT freed 424K, 6% free 9580K/10119K, paused 2ms+11ms
10-10 01:45:16.460: W/Ads(16797): Not enough space to show ad! Wants: <480, 75>, Has: <464, 708>
How can it be solved? The program does not force close, it can still execute but the ad just cannot show.
Also, the last row Logcat says not enough space? how to add more space for it? i have already reserved many space for it.
Many thanks in advance!
revised logcat:
The app can still be executed appearing without any error, but these “E” parts are there any effects on the proper execution of the app in some situation?
10-11 00:52:30.330: E/Ads(10023): An error occurred while destroying an AdWebView:
10-11 00:52:30.330: E/Ads(10023): java.lang.NullPointerException
10-11 00:52:30.330: E/Ads(10023): at android.webkit.WebView.setWebViewClient(WebView.java:5168)
10-11 00:52:30.330: E/Ads(10023): at com.google.ads.internal.AdWebView.destroy(SourceFile:252)
10-11 00:52:30.330: E/Ads(10023): at com.google.ads.internal.c$e.run(SourceFile:191)
10-11 00:52:30.330: E/Ads(10023): at android.os.Handler.handleCallback(Handler.java:605)
10-11 00:52:30.330: E/Ads(10023): at android.os.Handler.dispatchMessage(Handler.java:92)
10-11 00:52:30.330: E/Ads(10023): at android.os.Looper.loop(Looper.java:137)
10-11 00:52:30.330: E/Ads(10023): at android.app.ActivityThread.main(ActivityThread.java:4511)
10-11 00:52:30.330: E/Ads(10023): at java.lang.reflect.Method.invokeNative(Native Method)
10-11 00:52:30.330: E/Ads(10023): at java.lang.reflect.Method.invoke(Method.java:511)
10-11 00:52:30.330: E/Ads(10023): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
10-11 00:52:30.330: E/Ads(10023): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
10-11 00:52:30.330: E/Ads(10023): at dalvik.system.NativeStart.main(Native Method)
The issue is indeed:
For that device, you’ll need the entire width of the screen to show an ad in portrait. Part of the problem is the
android:padding="5dp"on your TableLayout.