Use AdRequest.Builder.addTestDevice("C874241999CEAE8512ED1C367CB593C2") to get test ads on this devi

2,491 views
Skip to first unread message

albert

unread,
May 31, 2016, 3:03:49 AM5/31/16
to Google Mobile Ads SDK Developers
log:
I/Ads: Starting ad request.
I/Ads: Use AdRequest.Builder.addTestDevice("AD29A37740A1E83D5335E46630E07FCA") to get test ads on this device.
after remove .addTestDevice("C874241999CEAE8512ED1C367CB593C2") , can not get ads
if we upload app to googleplay with addTestDevice("AD29A37740A1E83D5335E46630E07FCA") , will effect our  income; 

Message has been deleted

Dan Dragut

unread,
May 31, 2016, 6:12:32 AM5/31/16
to Google Mobile Ads SDK Developers
The deviceId string is particular to the device you're testing with, so no it should not affect your income when you release it.

However, you can wrap the .addTestDevice() sequence to test whether this is a debug build. That way you can do the final tests with the release APK later on this device to see if it gets production ads, before you upload it to the Google Play Store.


AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
if (BuildConfig.DEBUG) {
  adRequestBuilder
.addTestDevice("C874241999CEAE8512ED1C367CB593C2")
                  .addTestDevice("AD29A37740A1E83D5335E46630E07FCA")
                 
...;
}

albert

unread,
May 31, 2016, 7:40:17 AM5/31/16
to Google Mobile Ads SDK Developers
Thank you for your suggestion, but I still can not gets production ads with the release APK .
debug build can gets ads .
Will it work, if I update  compile 'com.google.android.gms:play-services-ads:8.4.0' to 
classpath 'com.google.gms:google-services:3.0.0'
compile 'com.google.firebase:firebase-ads:9.0.1'

AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
if (BuildConfig.DEBUG) {
    adRequestBuilder
.addTestDevice("C874241999CEAE8512ED1C367CB593C2")

                   
.addTestDevice("AD29A37740A1E83D5335E46630E07FCA");
}
adLoader
.loadAd(adRequestBuilder.build());


Vu Chau (Mobile Ads SDK Team)

unread,
May 31, 2016, 12:16:44 PM5/31/16
to Google Mobile Ads SDK Developers
Hi Albert,

To get production ads, you need to use a production ad unit ID.  In that case, you will no longer need the test device ID and any test ad unit IDs.

From your code snippets I didn't see any ad unit ID to test with, so let us know if creating an ad unit ID on AdMob.com serves to your app.

Vu Chau
Mobile Ads SDK Team

albert

unread,
May 31, 2016, 9:39:12 PM5/31/16
to Google Mobile Ads SDK Developers
Hi Vu Chau,
we created an ad unit ID,but can not get production ads with errorCode 0 ERROR_CODE_INTERNAL_ERROR .
something wrong in my code or my admob ad unit ID ,we regiester it on  AdMob.com and received a create succeed email from norepl...@google.com. 

private void preLoadAdmobAds(){
   
isAdmobAdError=false;

   
if(mFromActivity==FROMGALLERY){
       
Log.v("DataUtils","ADMOB_AD_UNIT_ID_GIFT_GALLERY");
       
builder = new AdLoader.Builder(mActivity, DataUtils.ADMOB_AD_UNIT_ID_GIFT_GALLERY);
   
}else{
       
Log.v("DataUtils","ADMOB_AD_UNIT_ID_GIFT_EDITER");
       
builder = new AdLoader.Builder(mActivity, DataUtils.ADMOB_AD_UNIT_ID_GIFT_EDITER);
   
}

   
builder.forContentAd(new NativeContentAd.OnContentAdLoadedListener() {
       
@Override
        public void onContentAdLoaded(NativeContentAd ad) {
           
adView = (NativeContentAdView) mActivity.getLayoutInflater().inflate(R.layout.admob_gift, null);
            populateContentAdView
(ad, adView);
           
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                   
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
           
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
           
((RelativeLayout) mIncludeAdmobAds).removeAllViews();
           
((RelativeLayout) mIncludeAdmobAds).addView(adView, params);
       
}
   
});

   
AdLoader adLoader = builder.withAdListener(new com.google.android.gms.ads.AdListener() {
       
@Override
        public void onAdFailedToLoad(int errorCode) {
           
Log.v("admob","onAdFailedToLoad"+""+errorCode);
           
isAdmobAdError=true;
           
//ToastUtil.showShortToast(mActivity, R.string.sns_msg_network_unavailable);
            //onBackClick();
        }

       
@Override
        public void onAdLoaded() {
           
super.onAdLoaded();
           
Log.v("admob", "onAdLoaded");
           
isAdmobAdLoaded=true;
           
if(giftId== LuckyDrawView.ADMOB_ADS){
               
mLuckyDrawSurfaceView.setIsAdsLoaded(isAdmobAdLoaded);
           
}
       
}
   
}).build();


   
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
   
if (BuildConfig.DEBUG) {

       
Log.v("DataUtils","DEBUG");

        adRequestBuilder
.addTestDevice("C874241999CEAE8512ED1C367CB593C2")
                       
.addTestDevice("AD29A37740A1E83D5335E46630E07FCA");
   
}
    adLoader
.loadAd(adRequestBuilder.build());

   
//adLoader.loadAd(new AdRequest.Builder().addTestDevice("C874241999CEAE8512ED1C367CB593C2").build());
    Log.v("admob", "admob");
}
private void populateContentAdView(NativeContentAd nativeContentAd,NativeContentAdView adView) {
    adView
.setHeadlineView(adView.findViewById(R.id.native_title));
    adView
.setImageView(adView.findViewById(R.id.native_coverImage));
    adView
.setBodyView(adView.findViewById(R.id.native_description));
    adView
.setCallToActionView(adView.findViewById(R.id.native_titleForAdButton));

   
((ImageView) adView.getImageView()).setImageDrawable(null);

   
((TextView) adView.getHeadlineView()).setText(nativeContentAd.getHeadline());
   
((TextView) adView.getBodyView()).setText(nativeContentAd.getBody());
   
((TextView) adView.getCallToActionView()).setText(nativeContentAd.getCallToAction());

   
List<com.google.android.gms.ads.formats.NativeAd.Image> images = nativeContentAd.getImages();
   
if (images.size() > 0) {
       
((ImageView) adView.getImageView()).setImageDrawable(images.get(0).getDrawable());
       
ViewGroup.LayoutParams params = adView.getImageView().getLayoutParams();
       
Log.v("width",""+adView.getWidth());
       
params.width = mIncludeFacebookAds.findViewById(R.id.native_coverImage).getWidth();
       
params.height = (int) (params.width / 1.9);
        adView
.getImageView().setLayoutParams(params);
   
}
    adView
.setNativeAd(nativeContentAd);
}


Vu Chau (Mobile Ads SDK Team)

unread,
Jun 1, 2016, 11:18:18 AM6/1/16
to Google Mobile Ads SDK Developers
Hi there,

Thanks for the clarification and the code snippets!

The code looks alright to me.  Since you didn't also provide an ad unit ID, I'm going to need you to test that ad unit ID in our sample app.  See if you could also obtain a meaningful Charles log at the time of the ad request.  A 0 error code can different causes, so we'd like to narrow down on them.

Vu Chau
Mobile Ads SDK Team

albert

unread,
Jun 2, 2016, 7:50:27 AM6/2/16
to Google Mobile Ads SDK Developers
Hi Vu Chau,
        Thanks for your help, we make a mistake between the Native Ads Advanced and the Native Ads Express.
Reply all
Reply to author
Forward
0 new messages