react-native-google-mobile-ads
react-native-google-mobile-ads copied to clipboard
[🐛] [Android] Interstitial ads won't load in release builds after upgrade to v7.0.0
Issue
After upgrading this library from v6.2.5 to v7.0.0 in my pet project, I noticed on Android that interstitial ads won't load anymore for me in release builds of the app, neither with test ads, nor with real ones. Somehow, they load fine when I build the code in development mode; banner ads also work fine. They also seem to work fine for me in example app, both with default test IDs, and when I copy/paste my app/add IDs into the example app config.
After some efforts to debug, I got nothing. All ads related logs from logcat look similar to me in dev and release mode, I checked that in both cases my code goes through the same checkpoints and does the same calls to the library, I see info messages like "This request is sent from a test device" in both cases, and it just never loads in release build.
Opening the ticket to check if anybody has similar experience?
Project Files
Javascript
Click To Expand
package.json
:
# N/A
admob.json
:
# N/A
iOS
Click To Expand
ios/Podfile
:
# N/A
Android
Click To Expand
android/build.gradle
:
// N/A
android/app/build.gradle
:
// N/A
android/settings.gradle
:
// N/A
AndroidManifest.xml
:
<!-- N/A -->
Environment
Click To Expand
react-native info
output:
OUTPUT GOES HERE
-
Platform that you're experiencing the issue on:
- [ ] iOS
- [ ] Android
- [ ] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
-
Are you using
TypeScript
?-
Y/N
&VERSION
-
- 👉 Check out
Invertase
on Twitter for updates on the library.
Ahh, would you try adding following to proguard-rules.pro? I am suspecting it's minify related problem.
-keep class io.invertase.googlemobileads.** { *; }
Thanks for the idea @wjaykim , but that does not seem to make any difference in this case.
@wjaykim Ha! But if I disable minification with Proguard altogether, then Interstitial ads do work for me :) I guess, I now just have to figure out what class should be kept... probably something from Google Ads SDK.
Thanks for logging thus and you have my condolences that it's a proguard thing. You might search in their forum or at least post there, they are responsive.
The SDK updates themselves/ the specific versions we changed to may be overridden even so you could find the version of their SDK where it broke maybe. I don't think we had forward or backward compatible issues on the underlying SDK movement.
I guess that means there is a workaround so you can release again, of downgrading, unless you also need react-native-firebase v15...
It looks like
-keep public class com.google.android.gms.ads.** { public *; }
does the trick.
Copied it from this example: https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/admob/InterstitialExample/app/proguard-rules.pro Not sure, though, should I copy the rest of the Proguard from that example, just in case, or as far as it seems to work with that one line it is fine? I mean, it seems to work alright, but can it be that it silently cuts down something behind the scene affecting possible ad revenues? What do you think?
And thanks to you @wjaykim , you saved my day.
I wish I could say but the SDKs are unfortunately opaque. I see mentions of proguard errors/fixes in rel-notes https://developers.google.com/admob/android/rel-notes I think they should have a proguard definition in their library that works, and a failure to do so should be considered a bug
Here's a similar issue https://groups.google.com/g/google-admob-ads-sdk/c/lX3qGEH1uWI/m/RBksSwwGAwAJ and the linked document has you include some IronSource mediation stuff (it's their docs, so of course...) along with the line you added: https://developers.ironsrc.com/ironsource-mobile/android/android-sdk/#step-5
I raised this on their forum directly: https://groups.google.com/g/google-admob-ads-sdk/c/GBSJMQzi5iI
Hey @mikehardy , one other thing, while on this I noticed in logcat outputs this warning:
W/Ads: Disabling data collection. Found google_app_id in strings.xml but Google Analytics for Firebase is missing. Remove this value or add Google Analytics for Firebase to resume data collection.
That is despite of me using Firebase with Google Analytics for Firebase (all via react-native-firebase), and seemingly analytics data on their own are captured fine by Firebase. Thoughts? Is the Ads library missing some piece after splitting from rn-firebase?
@birdofpreyru they need your help with a repro for the minification + interstitial thing I guess? You might be able to take their quickstart example you linked to and modify it slightly in order to demonstrate with low effort, otherwise I think it'll go stale as they won't take a react-native repo and they'll clearly block until they get a repro :shrug:
As for the second question about google firebase for analytics + google-mobile-ads data collection can you attest you have done all the things here (looks like user metrics needs to be enabled on admob side at minimum?) https://firebase.google.com/docs/admob/analytics-and-firebase?platform=android
also, perhaps after linking firebase project to admob you need to download a fresh google-services.json from firebase web console for project (assuming I remembered the filename correctly, sorry if not but you know what I mean)
@mikehardy
they need your help with a repro for the minification + interstitial thing I guess? You might be able to take their quickstart example you linked to and modify it slightly in order to demonstrate with low effort, otherwise I think it'll go stale as they won't take a react-native repo and they'll clearly block until they get a repro
Well, if with the info you already provided them, they don't consider it worth to spend their engineering resource to QA one of their core-business SDKs, I believe I just have no right to spend my own engineering resource to help them with it :rofl:
As for the second question about google firebase for analytics + google-mobile-ads data collection can you attest you have done all the things here (looks like user metrics needs to be enabled on admob side at minimum?)
Thanks for the link. At the first glance, I have all setup described there in place, but I'll double-check.
Well, speaking as a maintainer of a lot of repos:
Well, if with the info you already provided them, they don't consider it worth to spend their engineering resource to QA one of their core-business SDKs, I believe I just have no right to spend my own engineering resource to help them with it rofl
This is a little uncharitable, they get something like 10-20 problem reports a day as do I, and the vast majority of them result in a final resolution that can be summarized with "user was doing something wrong". It's actually pretty rare it's a bug vs just regular user help desk stuff. Asking for a reproduction is the only way to manage time in that sense and frequently results in the user determining that they were doing it wrong, with the reproduction attempt failure providing the enlightment
Also, we (this module) already has 1 strike against us with reproduction on their part - they cannot reproduce this issue I'm having #109 and I haven't been able to give them one.
So it's a reasonable request actually, and their examples provide a very low-friction way to tune in minification without the proguard rule, use the test app ids and poof - it should repro?
C'mon, they are Google, with 140k employees they easily can put an intern or few to test 10-20 problems a day with this SDK, or more. Probably, they just don't wanna be too helpful when they see react-native, cause that's Meta's stuff :rofl:
I work directly with google employees on firebase-related issues all the time and they are frequently motivated to really try our react-native reproductions but literally don't even have node installed, and their repros fail despite our react-native-firebase tests README. Had that happen just a few weeks ago with someone I know was really trying and I was really trying to help them bring a react-native harness up. :shrug: So my answer is either "probably not" or "been burnt so frequently on 'exotic' repros that they just enforce one that runs out of the box as a minimum standard"
Or it could be subtle pro-Flutter shade haha
I also ran into some similar issue .. is there a way to check why the loading does not run @mikehardy ? I can see in my logs that the load()
function definitely runs, but the result is still is isloaded: false
. The same happens only on android and I am running the version 7.0.1 of this package. Adding the proguard rule or even the whole file did not really help me - anything I need to do to make the changes take an effect? I cleaned the build, rebuild and cleaned caches? :(
@SakeFabi Though, does it work for you with Proguard disabled for the build? Like setting minifyEnabled
to false in build.gradle
? If it does, probably you are still missing a few Proguard rules, otherwise your issue is probably different.
hey @birdofpreyru, thanks for your quick reply. I guess it actually is true. Setting minifyEnabled to false does not help the cause and actually it is RewardedInterstitialAds that do not work on android for me. Even in a separate small test project I cannot get those to run, they just don't seem to load while interstitial ads work like a charm and so do banners. As I mentioned on iOS all fine and works very well.
well, I checked again - on Android neither RewardedInterstitialAds nor just RewardedAds load. Banners and Interstitial Ads load and are shown, while on iOS same code works like a charm. Any ideas here or should I open another Issue?
Strange indeed, I see rewarded ads when I run our test app, just not interstitial ads of any type (#109) - when I run the example app every thing works except interstitial and rewarded interstitial
Actually I got it to run now, had to add the Admob ID in the manifest though, which is not described in the installation documentation, is it? - Now all works fine on both platforms in clean test app and also my other projects.
That's really odd @SakeFabi - not only is that not needed (according to what we think we know at the moment...) but I made it so that if the app.json ad id lookup --> replace in manifest doesn't work it should actually fail the build
It definitely is, but there is not much more I did. :S
Just passing by to confirm that those lines are necessary to be added in proguard for it to work in production.
-keep public class com.google.android.gms.ads.** { public *; }
Was working fine in development; built a production release, it would initialize the plugin just fine, then upon loading a rewarded ad video it would crash. The adb logcat was clearly mentioning something about com.google.android.gms.ads
Now releasing to actual production, fingers crossed it doesn't break on some random devices for some unknown reason. :)
@pierroo thanks - feeling with you :D
Hi, I was having the same issue: load()
is correctly called and there is no error, but isLoaded
didn't turn to true
in release build for interstitial ads.
It already smelled like some missing proguard rule and then I came across this thread. I fixed this by adding this line as mentioned by @birdofpreyru and @pierroo:
-keep public class com.google.android.gms.ads.** { public *; }
Thank you everyone, and thank you @mikehardy for your work! :)
Quick update on this one: I'm definitely seeing some release build strange-ness with the load status now that I'm working through android release build items. I'm about to do a release now that at least fixes minification in release builds, without having to do any proguard setup, but I think the load event stuff will persist / be incorrect for a while longer as I've run out of timebox to inspect it I have added load status to the test app for the full screen ad types and I've added support for new "release" runscript targets in package.json so it's easy to reproduce now at least.
:tada: This issue has been resolved in version 8.1.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
I'm still having facing this issue in version 10.0.0. If app is in debug mode, everything work well, but when I generate an APK the interstitial don't load and somentimes crash the app. I tested in physical devices with android 9, 10, 11 and 12. Only in a Motorola EDGE 30 it works fine.
I did the proguard procedure, the minify and shrink are enable=false. Do you have any ideas about it?