【发布时间】:2013-12-07 12:33:05
【问题描述】:
好的,我来这里之前做了很多研究(对不起我的英语)。
我的问题是:我制作了一个应用程序并实现了 Admob 4.3.1(我的应用程序是在 Android 3.2(使用 eclipse)上开发的。
我第一次遇到错误“您必须具有 INTERNET 和 ACCESS_NETWORK_STATE 权限,我将它们放在我的 AndroidManifest.xml 中,现在一切正常,但是当我启动我的应用程序时,我的广告没有显示。
希望你能尽快帮助我...非常感谢。
这是我的 AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.package.sound"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/gg"
android:label="@string/app_name" >
<activity
android:name=".testpackagesound"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".test1"
android:label="@string/app_name" >
</activity>
<activity
android:name=".test2"
android:label="@string/app_name" >
</activity>
<activity
android:name=".test3"
android:label="@string/app_name">
</activity>
<meta-data android:value="xxxxxxxxxxxx" android:name="ADMOB_PUBLISHER_ID" />
<uses-sdk android:minSdkVersion="7" />
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/image"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="test1"
android:textColor="#005113" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="test2"
android:textColor="#970000" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="test3"
android:textColor="#001760" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dip" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxx"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fillViewport="true" >
<LinearLayout
android:layout_width="300px"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_gravity="center_horizontal"
>
<Button
android:id="@+id/button4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test4" />
<Button
android:id="@+id/button18"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test18" />
</LinearLayout>
</ScrollView>
</LinearLayout>
【问题讨论】:
-
代码看起来没问题;我不认为 SDK 使用 ADMOB_PUBLISHER_ID,但这不应该有任何影响。检查 logcat 输出,看看 SDK 给你什么样的消息。