Admob广告未在android模拟器上显示
我添加了admob代码,用于在我的应用程序中显示广告。当我在emulator中运行应用程序时,它会打开启动屏幕,然后应用程序突然退出,并说“很遗憾,您的应用程序已停止”。我不知道为什么会这样。它在添加admob代码之前运行良好。我还添加了代码。帮我做这个Admob广告未在android模拟器上显示,android,admob,Android,Admob,我添加了admob代码,用于在我的应用程序中显示广告。当我在emulator中运行应用程序时,它会打开启动屏幕,然后应用程序突然退出,并说“很遗憾,您的应用程序已停止”。我不知道为什么会这样。它在添加admob代码之前运行良好。我还添加了代码。帮我做这个 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"``
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background2" >
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="60dp"
android:background="@null"
android:padding="30dp"
android:src="@drawable/menu1"
android:contentDescription="@string/image_desc" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageButton1"
android:background="@null"
android:padding="30dp"
android:src="@drawable/menu2"
android:contentDescription="@string/image_desc" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageButton2"
android:background="@null"
android:padding="30dp"
android:src="@drawable/menu3"
android:contentDescription="@string/image_desc" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageButton3"
android:background="@null"
android:padding="30dp"
android:src="@drawable/menu4"
android:contentDescription="@string/image_desc" />
<ImageButton
android:id="@+id/imageButton5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageButton4"
android:background="@null"
android:padding="30dp"
android:src="@drawable/menu5"
android:contentDescription="@string/image_desc" />
</LinearLayout>
</ScrollView>
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="admob id"
ads:adSize="SMART_BANNER"
ads:loadAdOnCreate="true"/>
</RelativeLayout>
添加GoogleAddMobsdk可能会有问题,请通过此链接访问自己进行交叉检查。我认为我可以在您的应用程序中找到至少一个问题,您的admob规范中缺少一个重要字段,您必须在布局中添加该行:
ads:adUnitId="yourunitid"
ads:testDevices="TEST_EMULATOR"
为了获得您的单位id,您必须在admob网站上注册您的应用程序,如下所示:
你必须考虑的另一件事是,如果你刚刚插入了应用程序,横幅通常只显示在几个小时之后。
最后,我建议您在布局中添加该行:
ads:adUnitId="yourunitid"
ads:testDevices="TEST_EMULATOR"
因此,您对admob说,只向您的设备发送“测试”横幅(这样可以防止被禁止的风险)
所以你的建议应该是:
然后,如果它不能帮助添加logcat输出。您可以发布错误日志吗?您是否已将AdMob添加到清单文件中?@danijoo:是的,我已将AdMob添加到清单文件中。还添加了以下使用权限@CBergson错误日志显示2条警告。警告1:EGit无法检测安装路径。因此,EGit无法遵守系统级别。警告2:未设置环境变量HOME。请检查我不确定,但这可能是问题所在。在com.google.ads.AdView标记中的xml中,检查以下行ads:adUnitId=“admob id”。你能在这个adUnitId中传递这样一个值吗。是admobid。我想你不能在这里通行。