これを何度も試してみると、このエラーがどのように発生するのかわかりません。この後、この問題を投稿します。Admob 広告を追加したい開発中の 2.3.3 Android アプリがあります。私のエラー:
ここに私の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|screenLayout|uiMode|screenSize|smallestScreenSize"
代わりにこれを試しますandroid:configChanges="keyboard|keyboardHidden|orientation"
が、効果はありません。
そして 、外部 jar ファイルからGoogleAdMobAdsSdk-6.1.0.jarを追加します。