0

このプロジェクトは、AdMobページの例からほぼ正確に対処されましたが、それでも機能しません。これが私のクラスファイルです:

 package com.firecow.admobtest;

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

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

/**
 * A simple {@link Activity} that embeds an AdView.
 */
public class AdMobTesterActivity extends Activity {
    /** The view to show the ad. */
    private AdView adView;

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

        // Create an ad.
        adView = new AdView(this, AdSize.BANNER, "a14fd022edb48e8");

        // Add the AdView to the view hierarchy. The view will have no size
        // until the ad is loaded.
        LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
        layout.addView(adView);

        // Create an ad request. Check logcat output for the hashed device ID to
        // get test ads on a physical device.
        AdRequest adRequest = new AdRequest();
        adRequest.addTestDevice(AdRequest.TEST_EMULATOR);

        // Start loading the ad in the background.
        adView.loadAd(adRequest);
    }

    /** Called before the activity is destroyed. */
    @Override
    public void onDestroy() {
        // Destroy the AdView.
        if (adView != null) {
            adView.destroy();
        }

        super.onDestroy();
    }
}

...そして私のマニフェスト:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    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" />

</LinearLayout>

私は何をすべきかわからない、私はlogcatでこのエラーを受け取るだけです

java.lang.NoClassDefFoundError: com.google.ads.AdView

これは何を意味するのでしょうか?助けてください!

4

2 に答える 2

1

プロジェクトにAdMobSDKを含める必要があります。Eclipseを使用している場合、このチュートリアルではその方法を説明します。

SDKをまだダウンロードしていない場合は、AdMobコントロールパネルまたはここからダウンロードできます。

最後に、AndroidManifest.xmlファイルを確認します。同じチュートリアルで太字になっているコード行が追加されているはずです。(補足:マニフェストではなく、レイアウトファイルを表示しました。)

また、これを行った後、プロジェクトをクリーンアップして再構築したことを確認してください。

于 2012-06-14T00:35:03.873 に答える
0

admob.jarをlibsフォルダーにコピーしたことを確認し、Menifest.xmlにadmobアクティビティタグを追加することを忘れないでください

<activity
    android:name="com.google.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
于 2013-08-15T12:30:32.253 に答える