Android Admob示例错误:(
这个项目在admob页面上的示例中处理得很好,但仍然不起作用! 这是我的班级档案:Android Admob示例错误:(,android,admob,Android,Admob,这个项目在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.Line
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>
这意味着什么?请帮助!您需要在项目中包含AdMob SDK。如果您使用的是Eclipse,将向您展示如何做到这一点 如果尚未下载SDK,可以从AdMob控制面板或从下载 最后,检查您的
AndroidManifest.xml
文件。该文件应添加同一教程中以粗体显示的代码行。(旁注:您向我们展示了布局文件,而不是清单。)
另外,请确保完成此操作后已清理并重建项目。确保已将admob.jar复制到libs文件夹中,并且不要忘记在Menifest.xml中添加admob活动标记
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
我在一个新项目中完全遵循了教程,同样的事情也发生了……如果是这样,我相信这是一个libs错误。在教程中,它向您展示了如何添加库,但我相信在您的案例中它不会被导出。如果您需要知道如何将其添加到订单/导出列表中,请检查。
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>