2012-10-06 5 views
5

私はこのエラーがどのようになるのかわかりません、私はこのたくさんの時間を試してみましたので、stackoverflowのdiffernt postを見ましたが、私は解決策を得ています。だからこの後私はこの問題を投稿します。私は2.3.3アンドロイドアプリを開発しており、Admob広告を追加したいと考えています。 マイエラー:こここれはなぜですか?AndroidManifest.xmlにconfigChangesでAdActivityを宣言する必要があります。

enter image description here

私のjavaファイルで>グラフィカルなレイアウトで

package com.example.admobtest; 

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

import com.google.ads.*; 

public class MainActivity extends Activity { 
    private AdView adView; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     // Create the adView 
     adView=(AdView) findViewById(R.id.adView); 

     // Initiate a generic request to load it with an ad 
     adView.loadAd(new AdRequest()); 
    } 

} 

とmain.xmlファイル

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

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="17dp" 
     ads:adSize="BANNER" 
     ads:adUnitId="**************" 
     ads:loadAdOnCreate="true" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:text="@string/hello_world" 
     tools:context=".MainActivity" /> 

</RelativeLayout> 

- com.google.ads.AdView(オープンクラス、エラーログの表示)詳細については、エラーログ(ウィンドウ>表示の表示)を参照してください。

最後のAndroidManifest.xmlここ

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.admobtest" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="10" /> 
<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" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".MainActivity" 
      android:label="@string/title_activity_main" > 
      <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> 

に私はまた、代わりにandroid:configChanges="keyboard|keyboardHidden|orientation"のこのandroid:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"を試したが効果がないの。

そして、私はGoogleAdMobAdsSdk-6.1.0.jarをexterval jarファイルから追加します。

答えて

1

問題を解決するには、プロジェクトビルドターゲットをAndroid 3.2以降に設定する必要があります。

このリンクの詳細を確認してください。

https://developers.google.com/mobile-ads-sdk/docs/

+0

が、おかげで私の問題を解決するのに役立ちます願っていますがメタデータタグ

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/> 

を逃すと思います(Androidのタブを参照してください)。 –

関連する問題