1

こんにちは、アプリに広告を含めようとしました!!!

外部 jar を追加して、チュートリアルのように権限、アクティビティを追加しましたが、レイアウトに広告を追加すると問題が発生します

このエラーが表示されます

"java.lang.NullPointerException"

Min SDK バージョン Android 2.3.3 を使用しています

ターゲット 2.3.3

API レベル: 10

プロジェクトはビルドされますが、開きません!!!!

以下は私のコードです:

enter code here
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rhstudioss.adaps"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity android:name="com.google.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation"></activity>
    <activity
        android:name="com.rhstudioss.adaps.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

Main.xml

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="@string/hello_world" />
<com.google.ads.AdView android:id="@+id/ad"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adUnitId="MyID"
    ads:loadAdOnCreate="true"
    ads:adSize="BANNER"
    />

 </RelativeLayout>

問題のおかげで解決するのを手伝ってください:-)

4

2 に答える 2

0

adView を適切に配置したら、これを試してください。

ステップ 1:
- プロジェクトを右クリックします。
- 最新バージョンを使用している場合は、C:\Users\YOURNAME\android-sdks\extras\google\admob_ads_sdk で新しい Google_Admob_Jar ファイルを見つけます。
- [OK ] をクリックします。

ステップ 2:
- プロジェクトを右クリックします。
- プロパティ -> Java_Build_Path -> Order_and_Export。
- Google_Admob_Jar を選択します。
- [OK ] をクリック

します。お役に立てば幸いです :)

于 2013-01-15T09:06:26.997 に答える
0

あなたのコードで気づいたことがいくつかあります:

まず、ターゲット SDK は少なくとも API 13 である必要があります (参照リンク: Admob Error in Eclipse for android:configChanges ) 。

次のように変更します。

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="13"/>

次に、OP に投稿されたコードのこの部分:

<activity android:name="com.google.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation"></activity>

次のようにする必要があります。

<activity
    android:name="com.google.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>

アップデート

詳細については、このリンクを参照してください。サイトを開いたら、 [ Android ] タブに変更します (デフォルトでは iOS に表示されます)。

于 2013-01-13T07:13:54.210 に答える