Issues with Admob in r276.2

2 favourites
  • 2 posts
From the Asset Store
AdMob Plus PRO
$12.99 USD
[ Support C3 Build service ] Native Ad, App Open Ad, Banner Ad, Interstitial Ad, Rewarded Interstitial Ad, Rewarded Ad.
  • Background

    During the last beta cycle an issue with Admob started affecting some Android users. There seems to be a problem with the underlaying Ads SDK by Google because a similar problem has also been happening in other platforms, such a Unity for instance.

    To make things short, Construct needs to wait for the Ads SDK to finish initialization, and for some Android App Ids the SDK never finishes initialization and the app just freezes.

    This issue was reported in our tracker, you can find it here github.com/Scirra/Construct-3-bugs/issues/5211

    The initialization process is very quick, so to get around this issue, we implemented a timeout of 2 seconds in r273. What it does is very simple.

    If the SDK finishes initialization before the timeout is complete, then everything is ok.

    If the timeout finishes before initialization is complete then we are not sure what is going on, but to keep the app from freezing we assume ads failed to load. In this case the application does not freeze, but ads won't work.

    This is what Construct is doing in r276.2.

    Workarounds

    If you are seeing that ads are not working for you in r276.2, there is a possibility that you have an Android App Id which is causing problems and Construct is not initializing ads.

    We understand that for a lot of people, not freezing and ads not working is not enough, unfortunately there isn't much more that we can do because we simply don't have control over the cause of the problem. So if you are encountering that ads don't work in r276.2 you can try a couple of things.

    Create a new Android App Id and ad units

    Since the problem seems to be tied to certain Android App Ids, in my opinion, the easiest is to just create a new id. Head over to your Admob account and create a new app with corresponding new ad units. Once you have all your new ids, replace them in your C3 project and chances are high they will work.

    Manual patch

    If for any reason, you are not able to create a new Android App Id, you can try applying a manual patch to an Android Studio project export and then generate your APK or App Bundle using Android Studio.

    Follow these steps to apply the patch:

    1. Generate an Android Studio project export

    2. Open the project in Android Studio

    3. Find the file app/java/admob.plus/cordova/AdMob.java

    4. Find the following block of code at line 62

    case Actions.START:
    	MobileAds.initialize(cordova.getActivity(), status -> {
    		helper.configForTestLab();
    		callbackContext.success(new JSONObject(new HashMap<String, Object>() {{
    		 put("version", MobileAds.getVersionString());
    		}}));
     });
     break;
    

    5. Change it so it looks like this

    case Actions.START:
     MobileAds.initialize(cordova.getActivity());
    
     helper.configForTestLab();
     callbackContext.success(new JSONObject(new HashMap<String, Object>() {{
     put("version", MobileAds.getVersionString());
     }}));
     break;
    

    6. Try it in the simulator

    7. Generate APK or App bundle with the patch applied

    Hopefully in the future this issue will be fixed from Google's side and none of this will be needed anymore.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • For the ones interested there is always a lot of discussions on the official forum.

    There is a specific topic "Reproducable : MobileAds.Initialize() taking 8 seconds" for instance.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)