0

admob用のアプリケーションを作成しましたが、エラーが発生します。Googleの例を見つけて試しましたが、アプリケーションを起動するときに問題が発生します。

Android 2.2 API 8を使用しています。アプリケーションを起動できますが、このブロックが原因でエラーが発生しています。

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

これをに変更すると

android:configChanges="keyboard|keyboardHidden"

その後、アプリケーションを起動できますが、追加フィールドでエラーが発生します。

you must have adactivity declare in Android Manfiest.xml with config change

このため、アプリケーションでGoogleアドワーズ広告を表示できません。

これを修正するのを手伝ってください。

4

3 に答える 3

2

私はあなたがこのチュートリアルに従う必要があると思います。

そして特にあなたの問題はこの行についてであるはずです:

Android用のGoogleAdMobAds SDKには、Android1.5以降が必要です。Android SDKの最新のコピーがあり、少なくともAndroid v3.2に対してコンパイルしていることを確認してください(default.propertiesのターゲットをandroid-13に設定してください)。

つまり、minSDKは1.5まで下げることができますが、少なくとも3.2でコンパイルする必要があります。

于 2012-04-20T07:49:01.023 に答える
0

AdMobのドキュメントから

アクティビティタグ全体をAndroidManifest.xmlに追加する必要があります

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

https://developers.google.com/mobile-ads-sdk/docs/android/fundamentalsを参照してください

于 2012-04-20T07:46:38.293 に答える
0
 - AdActivity.java

package com.android.ads;

import android.app.Activity;
import android.os.Bundle;

import com.google.ads.AdRequest;
import com.google.ads.AdView;

public class AdsActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        AdView adview = (AdView) findViewById(R.id.adView);
        AdRequest re = new AdRequest();
        re.setTesting(true);
        re.setGender(AdRequest.Gender.FEMALE);
        adview.loadAd(re);
    }
}

 - main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

        xmlns:ads="http://schemas.android.com/apk/res/com.android.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

     <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="Your adunit ID" 
        android:layout_alignParentBottom="true"/>    
</LinearLayout>

Remember Put GoogleMapAdmobSdk.jar after creating libs folder for Configure build path 


Create the attrs.xml in the Values folder

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <declare-styleable name="com.google.ads.AdView">
      <attr name="adSize">
          <enum name="BANNER" value="1"/>
          <enum name="IAB_MRECT" value="2"/>
          <enum name="IAB_BANNER" value="3"/>
          <enum name="IAB_LEADERBOARD" value="4"/>
      </attr>
      <attr name="adUnitId" format="string"/>
  </declare-styleable>
</resources>

 - AndroidManifest

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

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".AdsActivity"
            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="com.google.ads.AdActivity"
                      android:configChanges="keyboard|keyboardHidden|orientation"/>
    </application>

</manifest>


Your work is done buddy............
于 2012-04-20T08:48:47.373 に答える