2
내 애플리케이션에 AdMob을 통합하려고하고 있는데 AdMob 예제를 성공적으로 확인했으며 내 Android 기기에 추가가되었지만 작동하지 않는 앱에 대해 동일한 코드를 수행하려고 할 때 ... 제발 도와주세요.Android, Admob
내 코드
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ads.example">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
</application>
</manifest>
Gradle을
private void startGame() {
// Request a new ad if one isn't already loaded, hide the button, and kick off the timer.
if (!mInterstitialAd.isLoading() && !mInterstitialAd.isLoaded()) {
runOnUiThread(new Runnable() {
@Override
public void run() {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("0C3BF98F2CA55F66D0BE2D63D962BF6D")
.build();
mInterstitialAd.loadAd(adRequest);
}
});
}
}
InterstitialAd mInterstitialAd;
void StartAds()
{
MobileAds.initialize(this, "ca-app-pub-3940256099942544~1033173712");
mInterstitialAd = new InterstitialAd(this);
// Defined in res/values/strings.xml
mInterstitialAd.setAdUnitId(getString(R.string.google_home_ad_unit_id));
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
}
});
if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
startGame();
}
}
매니페스트 파일
배너 광고의 경우 32,574,315,320,303,210