0

I am trying to implement admob ads in fragment but its been a month and i am still getting error 3 ( No ads to fill ).

i have tried with new Id but still getting same error, test ads are working fine. logcat:

 
    08-03 16:59:21.653 9892-10265/? W/AdvertisingIdClient: Error while reading from SharedPreferences
    java.lang.SecurityException: MODE_WORLD_READABLE no longer supported
    at android.app.ContextImpl.checkMode(ContextImpl.java:2134)
    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:354)
    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:349)
    at 
 com.google.android.gms.ads.identifier.AdvertisingIdClient.getAdvertisingIdInfo(Unknown Source)
    at com.duapps.ad.base.GoogleAdvertisingIdHelper.getAdIdNormal(GoogleAdvertisingIdHelper.java:46)
        at com.duapps.ad.base.GoogleAdvertisingIdHelper.getAdId(GoogleAdvertisingIdHelper.java:33)
        at com.duapps.ad.base.HttpParamsHelper.commonParams(HttpParamsHelper.java:118)
        at com.duapps.ad.stats.ToolStatsCore.pushToServer(ToolStatsCore.java:370)
        at com.duapps.ad.stats.ToolStatsCore.report(ToolStatsCore.java:325)
        at com.duapps.ad.stats.ToolStatsCore.handleMessage(ToolStatsCore.java:217)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:154)
        at android.os.HandlerThread.run(HandlerThread.java:61)
        08-03 16:59:24.873 26224-26246/? D/DynamitePackage: Instantiating 
        com.google.android.gms.ads.adshield.ChimeraAdShieldCreatorImpl
        08-03 16:59:25.489 25315-25315/com.nsdeveloper.apppromotion I/Ads: 
        Starting ad request.
        08-03 16:59:25.489 25315-25315/com.nsdeveloper.apppromotion I/Ads: Use 
       AdRequest.Builder.addTestDevice("10C9D896CF812C194BD949D82F766C9B") 
        to get test ads on this device.
        08-03 16:59:25.850 25315-25332/com.nsdeveloper.apppromotion I/Ads: No fill from ad server.
        08-03 16:59:25.850 25315-25315/com.nsdeveloper.apppromotion W/Ads: Failed to load ad: 3
 

I am implementing ads in fragment so in context i was passing getActivity() :

MobileAds.initialize(getActivity(), "xxxxxxxxxxxxxxxxxxx");
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(getActivity());
    mRewardedVideoAd.setRewardedVideoAdListener(rewardAdListener);
    loadRewardedAdVideo();

RewardVideoAdListener

RewardedVideoAdListener rewardAdListener = new RewardedVideoAdListener() {

    @Override
    public void onRewardedVideoAdLoaded() {
        Toast.makeText(getActivity(),"ad is loaded",Toast.LENGTH_SHORT).show();
        Log.d("ADS_SHOW","loaded");


    }

    @Override
    public void onRewardedVideoAdOpened() {

    }

    @Override
    public void onRewardedVideoStarted() {

    }

    @Override
    public void onRewardedVideoAdClosed() {
        loadRewardedAdVideo();
    }

    @Override
    public void onRewarded(RewardItem rewardItem) {
        int rewardPoints =   rewardItem.getAmount();
        int userPoints = getActivity().getSharedPreferences(PREFERENCE,0).getInt(POINTS,0) - rewardPoints;
        userRef.child(POINTS).setValue(userPoints);
        getActivity().getSharedPreferences(PREFERENCE,0).edit().putInt(POINTS,userPoints).commit();




    }

    @Override
    public void onRewardedVideoAdLeftApplication() {

    }

    @Override
    public void onRewardedVideoAdFailedToLoad(int i) {
        Toast.makeText(getActivity(),"No ads to show "+i,Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onRewardedVideoCompleted() {





    }
};


private void loadRewardedAdVideo(){
    if(! mRewardedVideoAd.isLoaded()){
         mRewardedVideoAd.loadAd("ca-app-pub-xxxxxxxxx", new AdRequest.Builder().build());
    }
}

Samir Shaikh
  • 46
  • 1
  • 1
  • 7
  • please show us the code for admob ads – Nirav Bhavsar Aug 03 '18 at 11:46
  • Are you using `SharePreference` in mode `MODE_WORLD_READABLE` anywhere in your code .? Post your code also. – ADM Aug 03 '18 at 11:48
  • I am using SharedPreferences with default mode 0 and i don't think so it was related to admob error – Samir Shaikh Aug 03 '18 at 11:59
  • Just Comment all code inside `onRewarded()` just print a log . And check whether you get error this time or not . – ADM Aug 03 '18 at 12:30
  • getting the same error @ADM – Samir Shaikh Aug 03 '18 at 12:47
  • Well i never worked with `admob` . But you should add the dependency you are using with question . Also See [This issue](https://github.com/adjust/android_sdk/issues/342). It can a version issue . Use latest dependency From [Here](https://developers.google.com/android/guides/setup). – ADM Aug 03 '18 at 12:51
  • I am using updated dependencies, and as I told test ads are perfectly working but when I'm using my id I am getting error 3 ( and its been a month i was getting this error) @ADM – Samir Shaikh Aug 03 '18 at 12:58

2 Answers2

1

I had the same problem - I read online that google can decide later if they turn your ads on or not.

Sometimes they turn ads off because the developer clicks on them. Many developers were doing so in the past and therefore google seems careful about it.

In the end I didn't resolve my issue with google - where I also wrote to their support and I registered with facebook network audience - it's the same, just facebook. Now I am getting them. There is also a system which allows you to register test devices - this means - by the ID of your phone, then you can also click on the adverts and there will be no problem with that - as it is now test device.

FB Rewarded Video

0

Try to run your ads on the test mode if it will show you the error then your code must be wrong read the doc of admob implementation Google docs for video ads

One thing i notied that you may be try to read the shared prefernece in the public mode it be written in the private mode thats why the error coming.

If u are seeing the ads in the test mode then there may me two things one your app id may be wrong second your area does not have the rewarded ads like this so google is not able to fill the ads

  • I have tried running ads on test mode and its working perfectly. and i am not using sharedPreference in public mode anywhere i have checked it two times. i have also tried by creating new app id. – Samir Shaikh Aug 05 '18 at 08:24
  • Make sure your app id and ad id's are correct or not it must not throw the error if it is working on the test mode – vaibhav sharma Aug 05 '18 at 08:27