Closed josephto closed 1 year ago
Careful with this - version skew detected:
"@react-native-firebase/analytics": "^17.3.2",
"@react-native-firebase/app": "^17.3.1",
"@react-native-firebase/messaging": "^17.3.1",
--> https://invertase.io/blog/react-native-firebase-versioning
PRs happily accepted if you can find a patch that works for you inside node_modules to fix the issue you describe, if I recall correctly during review we were pretty sure that the Activity there would also be something in the React object hierarchy thus the cast would succeed. Is your app some sort of brownfield / mixed react-native/non-react-native set of objects?
Is your app some sort of brownfield / mixed react-native/non-react-native set of objects?
No, not that I'm aware of. My app is a bare React Native app
Might be introduced by: https://github.com/invertase/react-native-google-mobile-ads/commit/3b1f34cb850d89555f6350d5c8b50e4c242a3a78 ?
UPDATE: could reproduce with our example app. Reverting https://github.com/invertase/react-native-google-mobile-ads/pull/345 fixes the issue (@aidan-24com).
Caused by: https://github.com/invertase/react-native-google-mobile-ads/blob/main/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeAdView.java#L19 Removing this line fixes the issue.
I reverted #345 and re-opened #188. If you update to 10.1.1 it should work fine again. Thanks for reporting!
apologies for the back and forth with this, but I believe the new PR is a cleaner approach and also only handful of lines
:tada: This issue has been resolved in version 10.1.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Exception is not being thrown anymore. However, I'm noticing that in development mode, the ads are properly sized to the width of the device, but in release mode, the ads are not. Anybody have a potential explanation for this?
Release:
Development:
@josephto are you using GAM ads?
@aidan-24com no, should I be? I'm not sure when i should use GAMBannerAd vs a BannerAd. Here is my relevant code snippet
const requestNonPersonalizedAdsOnly =
Platform.select({
ios: !(appTrackingTransparency === RESULTS.GRANTED),
android: false,
}) ?? false;
const bannerSize = BannerAdSize.ANCHORED_ADAPTIVE_BANNER;
return (
<AdsContext.Provider
value={{
topBannerAd:
showAds && appTrackingTransparency ? (
<Stack alignSelf="center">
<BannerAd
unitId={topBannerAdUnitId}
size={bannerSize}
requestOptions={{
requestNonPersonalizedAdsOnly,
}}
/>
</Stack>
) : null,
bottomBannerAd:
showAds && appTrackingTransparency ? (
<Stack alignSelf="center">
<BannerAd
unitId={bottomBannerAdUnitId}
size={bannerSize}
requestOptions={{
requestNonPersonalizedAdsOnly,
}}
/>
</Stack>
) : null,
}}
>
{children}
</AdsContext.Provider>
hmm, the change I made recently is now only for GAM banner ads. we only use GAM for our apps, so not sure why they are different for you.
maybe try use the same ad unit in both dev and release, to confirm that is not just the ads themselves?
I reverted #345 and re-opened #188. If you update to 10.1.1 it should work fine again. Thanks for reporting!
I think my question is related to @dylancom's comment above here that fixes the ANCHORED_ADAPTIVE_BANNER and not to your recent PR
The implementation seems fine. Also the Test Ad label on top suggests this. For a more detailed insight in why the admob inventory is returning a smaller ad in the available space you'd have to ask the AdMob forums. I would suggest testing on a real device with a production ready APK.
What happened?
Inside ReactNativeGoogleMobileAdsCommon.java's getAdSizeForAdaptiveBanner method (https://github.com/invertase/react-native-google-mobile-ads/blob/8bbfc058b20f599acc3fd91d0145c4f974bf2d09/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java#L46), the try catch throws and error:
Error thrown: java.lang.ClassCastException: {{com.myapp}}.MainActivity cannot be cast to com.facebook.react.bridge.ReactContext
As a result, the AdSize.Banner is always returned instead of an adaptive AdSize:
Platforms
Only on Android
React Native Info
Are your using Typescript?
package.json
app.json
ios/Podfile
android/build.gradle
android/app/build.gradle
android/settings.gradle
AndroidManifest.xml