2014-09-03 5 views
0

설명 : - Google의 최신 가이드 라인에 따라 내 앱을 'Google Play 서비스'SDK와 통합합니다. 이전에는 독립형 admob SDK와 통합되었습니다.Google Play 서비스 : 광고로드 문제

문제 : - 중 하나가 표시되면 배너 및 전체 광고가 제대로 표시됩니다. 그러나 둘 다 표시해야 할 때 예기치 않은 결과가 나타납니다.

예기치 않은 결과가 있습니까? 예, 배너 만로드되고 일부는 전체 광고 만 표시됩니다. 둘 다 보여지는 것은 매우 드뭅니다.

FIX : - 1. 나는 배너와 삽입 광고 사이에 약간의 지연을주고 조금 더 나은 결과를 얻었습니다. 그러나 여전히 결과는 대부분 예측할 수 없습니다.

  1. 전체 광고에는 비동기 작업을 사용했습니다. Background()에서 2 초의 지연을 주었고 PostExecute()에서 광고를로드했습니다. 훨씬 더 나은 결과를 제공합니다. 그러나 여전히 10 회 시도 중 7 회만 광고가 게재됩니다. 배너 또는 전체 중 3 번 중 나머지는로드되지 않습니다.

은 다음 주요 활동

package com.example.adtest_new; 
import android.app.Activity; 
import android.content.Context; 
import android.os.AsyncTask; 
import android.os.Bundle; 
import android.widget.Toast; 

import com.google.android.gms.ads.AdListener; 
import com.google.android.gms.ads.AdRequest; 
import com.google.android.gms.ads.AdView; 
import com.google.android.gms.ads.InterstitialAd; 

public class MainActivity extends Activity 
{ 
Context myCont=null; 
private InterstitialAd interstitial = null; 
AdRequest adr; 

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    //Get the view from activity_main.xml 
    setContentView(R.layout.activity_main); 

    myCont = this; 

    //--------------BANNER AD----------------------------------  
    //Locate the Banner Ad in activity_main.xml 
    AdView adView = (AdView) this.findViewById(R.id.adView); 
    // Request for Ads 
    AdRequest adRequest = new AdRequest.Builder().build(); 
    // Load ads into Banner Ads 
    adView.loadAd(adRequest); 
    //--------------BANNER AD----------------------------------   

//Fix-1 (Did not work) 
    try{Thread.sleep(2*1000);}catch(Exception e){}   

//Fix-2 (Did not work) 
//Called Asynch task here(put delay of 2 seconds in background() and loaded full ad in postexecute()) 

    //--------------FULL AD---------------------------------- 
    //Prepare the Interstitial Ad 
    interstitial = new InterstitialAd(MainActivity.this);   

    //Insert the Ad Unit ID 
    interstitial.setAdUnitId("ca-app-pub-465697675827xxxx/xxxxxxxxxx"); 
    adr = new AdRequest.Builder().build(); 
    //Load ads into Interstitial Ads 

    //Prepare an Interstitial Ad Listener 
    interstitial.setAdListener(new AdListener() 
    { 
     public void onAdLoaded() 
     { 
      //System.out.println("!!! Full Ad loaded !!!"); 
      Toast.makeText(myCont, "!!! Full Ad loaded !!!", Toast.LENGTH_SHORT).show(); 
      //Call displayInterstitial() function 
      displayInterstitial(); 
     } 
    });   
    interstitial.loadAd(adr);  
    //--------------FULL AD---------------------------------- 
}  

public void displayInterstitial() { 
    // If Ads are loaded, show Interstitial else show nothing. 
    if (interstitial.isLoaded()) 
    { 
     interstitial.show(); 
    } 
} 

}

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/openedWindows" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#ffffff" 
android:orientation="vertical" > 


<TextView 
    android:id="@+id/completePath" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="left" 
    android:layout_marginTop="0dp" 
    android:layout_marginLeft="3dp" 
    android:text="/mnt/sdcard" 
    android:textColor="#ff2d8df1" 
    android:textSize="16dip" 
    android:textStyle="bold" 
    android:typeface="sans"/> 

<View 
android:id="@+id/bar0" 
android:layout_width="fill_parent" 
android:layout_height="1dp" 
android:layout_marginTop="0dp" 
android:background="#ffb2cb39"  
android:layout_marginBottom="0dp"/> 



<View 
android:id="@+id/bar1" 
android:layout_width="fill_parent" 
android:layout_height="1dp" 
android:layout_marginTop="0dp" 
android:background="#ffb2cb39"  
android:layout_marginBottom="1dp"/> 


<RelativeLayout  
android:id="@+id/temp" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@android:color/transparent" 
android:layout_marginTop="5dp" 
android:layout_marginBottom="5dp" 
android:orientation="vertical"> 

<Button 
    android:id="@+id/selectAll" 
    android:layout_width="wrap_content" 
    android:layout_height="25dp" 
    android:layout_gravity="left" 
    android:layout_marginBottom="1dp" 
    android:layout_marginLeft="15dp" 
    android:layout_alignParentLeft="true" 
    android:background="@drawable/button_green" 
    android:textSize="15dip" 
    android:text="BUTTON1" 
    android:paddingLeft="10px" 
    android:paddingRight="10px" 
    android:textColor="#ffffff" 
    android:textStyle="bold" /> 

<Button 
    android:id="@+id/selectBtn" 
    android:layout_width="wrap_content" 
    android:layout_height="25dp" 
    android:layout_marginRight="15dp" 
    android:layout_marginBottom="1dp" 
    android:layout_alignParentRight="true" 
    android:background="@drawable/button_green" 
    android:textSize="15dip" 
    android:text="BUTTON2" 
    android:paddingLeft="10px" 
    android:paddingRight="10px" 
    android:textColor="#ffffff" 
    android:textStyle="bold" /> 
</RelativeLayout> 


<View 
android:layout_width="fill_parent" 
android:layout_height="1dp" 
android:layout_above="@+id/tableRow2" 
android:background="#444444"  
android:layout_marginBottom="0dp"/> 

<TableRow 
android:id="@+id/tableRow2" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 
<com.google.android.gms.ads.AdView 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/adView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="ca-app-pub-465697675827xxxx/xxxxxxxxxx" 
    />  
</TableRow> 

</LinearLayout> 

매니페스트

activity_main.xml의 코드

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.adtest_new" 
    android:versionCode="1" 
    android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="9" 
    android:targetSdkVersion="21" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" > 
     <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"/> 
    <meta-data android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version"/> 

</application> 

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 

</manifest> 

이 문제를 해결하는 방법을 알려주세요. ?? 독립형 admob SDK는 두 가지 광고 유형 모두에서 올바르게 작동합니다.

답변

0

테스트 디바이스를 선언하지 않았으므로 "실제"광고 (테스트 광고 아님)를로드하고있는 것으로 나타났습니다. 나는 내가 말하는 것에 대해 100 % 확신하지는 못했지만 이것이 아마도 문제의 원인 일 수 있습니다. 실제 광고를 표시 할 때 항상 Admob/Google Play 서비스에서 제공되는 광고가있는 것은 아니기 때문에 광고가 표시되지 않는 경우가 있습니다 (로드 오류 코드는 3으로 채우기가 없음). 항상 사용할 수있는 테스트 광고를 사용하게하는 테스트 장치를 선언하면서 테스트 할 수 있습니다.

또한 개발자가 실수로 테스트를하거나 실수로 많은 광고를 클릭하면 AdMob에서 금지 될 수 있으므로 개발 중에 테스트 장치를 사용하는 것이 좋습니다.

당신은 거짓 노출을 방지하려면 개발 과정에서 테스트 광고를 사용해야이

테스트 광고

을, CF 테스트 장치를 추가하는 방법을 참조하십시오. 또한 언제든지 테스트 광고를 활용할 수 있습니다. 해시 된 기기 ID를 AdRequest.Builder로 전달하여 테스트 광고를 설정합니다.addTestDevice :되는 AdRequest 요청 = 새로운 AdRequest.Builder() .addTestDevice (AdRequest.DEVICE_ID_EMULATOR) // 모든 에뮬레이터 .addTestDevice ("AC98C820A50B4AD8A2106EDE96FB87D4") // 내 갤럭시 넥서스 테스트 전화 .build();

편의를 위해 logcat은 dev에에게

얼음의 MD5 해시 ID를 출력합니다 : 사용 AdRequest.Builder.addTestDevice ("AC98C820A50B4AD8A2106EDE96FB87D4")를이 장치에 GET 테스트 광고.

(https://developers.google.com/mobile-ads-sdk/docs/admob/android/banner)

어떤 사람들은 휴대 전화가 영어가 아닌 경우 그 테스트 광고가 제대로 작동하지 않는 말을

테이크 관리 (AdMob test ads shows only on English devices)

편집 : 앱 물론 실제 사용자 것이다 진짜 광고를 사용하십시오, 그래서 그들은 또한 항상 유효한 광고의 "문제"를 경험할지도 모릅니다, 그러나 이것은 정상적입니다. 정기적으로 새로운로드 일정을 잡을 수 있습니다 (삽입 광고의 경우 배너가 정기적으로 새로 고침 됨).

편집 2 : 그건 그렇고, 이것은 당신의 문제와는 조금 관련이 없을 수도 있지만 일반적으로 사람들은 AdListener.onAdLoaded 메소드에서 광고를 표시하지 말 것을 강력히 권유하지만 원하는 순간에 수동으로 호출하도록 권장합니다. 표시됩니다 (isLoaded가 true 인 경우). 하지만 이것은 인체 공학적 고려 일 뿐이며 버그가없는 사람도 아닙니다