Android 용 게임을 개발하는 초기 단계에 있으며 AdMob을 사용하여 광고 배너를 통합하려고합니다. 공식 site에있는 튜토리얼에서 바로 샘플을 다운로드 했으므로 여기서 잘못하고있는 것은 몇 초 후에 Galaxy S2 디바이스에서 디버깅 할 때 기본이되어야한다고 생각합니다. 플레 도움.AdMob 간단한 안내서가 작동하지 않습니다.
package com.google.example.ads.fundamentals;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.LinearLayout;
/**
* A simple {@link Activity} that embeds an AdView.
*/
public class BannerSample extends Activity {
private AdView adView;
private final TelephonyManager tm =
(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
private final String AD_MOB_ID = "my AdMob ID goes here";
/** 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, AD_MOB_ID);
// Add the AdView to the view hierarchy. The view will have no size
// until the ad is loaded.
LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
layout.addView(adView);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(tm.getDeviceId());
// 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();
}
}
스크린 샷의 로그 캣 데이터는 here
편집이다 : 나는 또한이 의심 Manifest.XML을 추가, 어떤 문제를 causeing - 공식 사이트에서 예제와 함께 놀랍게도 하나 (이클립스)에 따라 거기에 오류가 있었다, 그래서 나는 그것을 조금 수정했다 :
이<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="3"
android:targetSdkVersion="13" />
<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">
<activity
android:name=".HelloAdMobActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:screenOrientation="landscape" >
<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|screenLayout|uiMode|screenSize|smallestScreenSize"
android:screenOrientation="landscape" >
</activity>
</application>
</manifest>
스택 오버 플로우에 오신 것을 환영합니다! 충돌에 관한 어떤 로그캣 정보가 있습니까? – gobernador