這個項目是由AdMob的頁面上的例子幾乎應付exacatly,但它仍然無法正常工作 這裏是我的類文件:Android的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
做什麼這意味着什麼?請幫忙!
我完全跟着turorial在一個新的項目,並同發生的事情... – naughtyburritos
如果是這樣的話,我認爲這是一個庫錯誤。在教程中,它向您展示瞭如何添加庫,但我相信你的情況下它不會被導出。如果您需要知道如何將其添加到訂單/導出列表中,請選中** [here](http://android.okhelp.cz/noclassdeffounderror-com-google-ads-adview-adt-17/)** 。 – Eric