【发布时间】:2014-01-02 02:30:31
【问题描述】:
我在使用 google admob 时出错。手机屏幕大于 4" 时一切正常,但如果小于 4",则不会显示广告。在模拟器上我收到此错误
空间不足,无法展示广告!想要:,你
这是我的代码
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads">
<com.google.ads.AdView
android:id="@+id/lytMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="id"
ads:loadAdOnCreate="true" />
这是java代码
lytMain = (LinearLayout) findViewById(R.id.lytMain);
adView = new AdView(this, AdSize.BANNER, "Num google");
lytMain.addView(adView);
adView.bringToFront();
adView.loadAd(new AdRequest());
在屏幕为 4" 的 android 2.3 中不起作用:/ 仅适用于 4" 以上的屏幕和 4.0 以上的 android
我编辑了代码,现在看到这个错误
The following classes could not be instantiated:
- com.google.ads.AdView (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
java.lang.ClassNotFoundException: org.json.JSONException
at java.net.URLClassLoader$1.run( at java.net.URLClassLoader$1.run( at java.security.AccessController.doPrivileged( at java.net.URLClassLoader.findClass( at java.lang.ClassLoader.loadClass( at java.lang.ClassLoader.loadClass( at com.google.ads.AdView.a(SourceFile:184)
at com.google.ads.AdView.a(SourceFile:352)
at com.google.ads.AdView.<init>(SourceFile:125)
【问题讨论】:
-
请为
AdSize.BANNER留出至少 320x50px 的空间。