Hi
We are experiencing a lot of crashes regarding the ads plugin but we're not sure what is causing the issue.
We initialize ads ONCE at the start of the game. Is this the best approach? How do you implement ads in your game?
Could our issues be related to pause / resume?
Here's an example of a recent crash:
Example:
java.lang.NullPointerException:
at com.giderosmobile.android.plugins.ads.frameworks.AdsAdmob.showAd (AdsAdmob.java:416)
at com.giderosmobile.android.plugins.ads.Ads$8.run (Ads.java:355)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:7325)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120
We are using Gideros 2018.10
Does anyone have any ideas?
Cheers
Simon
Comments
If I was concerned that suspend/resume might be an issue I'd probably throw some more code into my game scene..
Likes: Apollo14, simwhi
Likes: SinisterSoft, simwhi
public void showAd(final Object parameters)
{
Log.i("AdsAdmob", "showAd");
SparseArray param = (SparseArray)parameters;
String type = param.get(0);
if(adsManager.get(type) == null)
{
loadAd(parameters);
}
adsManager.show(type);
}
Line 416 relates to loadAd(parameters);
In this method, I can see only two ways to get a NPE:
1° parameter is null, thus param.get(0) will trigger NPE
2° adsManager is null, and either adsManager.get(type) or adsManager.show(type) will trigger NPE
Maybe AdsManager was cleared up (app closing) before the event was triggered ?
Likes: simwhi
This is what I did:
1. I added code to the adsAdmob. java to determine whether the user is in the EEA or not using the the Google consent API on initialization.
2. I hijacked the error event to send EEA or non EEA back to Lua.
3. We show a GDPR dialogue for EEA users to accept NPA ads only. We decided not to show personalized ads.
4. The user cannot use our app unless they consent to NPA. We save this consent in our user preferences file.
If you would like any code snippets I am happy to assist.
Cheers
Simon