Android: Could not invoke RNAdmobNativeAdsManager.registerRepository null
ertan95 opened this issue · 3 comments
Could not invoke RNAdmobNativeAdsManager.registerRepository null No virtual method addNetworkExtrasBundle(Ljava/ lang/Class;Landroid/os/Bundle;)Lcom/google/ android/gms/ads/AdRequest$Builder; in class Lcom/google/android/gms/ads/admanager/ AdManagerAdRequest$Builder; or its super classes (declaration of 'com.google.android.gms.ads.adm anager.AdManagerAdRequest$Builder' appears in /data/app/~~mWuG9hM6K2JIn3wrOzDkEg==/
I did the setup as described in the docs. It works on iOS but I'm getting the error above for Android on the emulator. I use it this way:
import { AdManager } from 'react-native-admob-native-ads';
const preloadAds = async (consentStatus: number) => {
console.log('Preloading ads', consentStatus);
if (__DEV__) {
AdManager.setRequestConfiguration({
testDeviceIds: TEST_DEVICE_IDS,
});
}
try {
// Preload ads on app start
const result = await AdManager.registerRepository({
adUnitId: __DEV__ ? TEST_CAROUSEL_NATIVE_AD_ID : CAROUSEL_NATIVE_AD_ID,
numOfAds: 3,
requestNonPersonalizedAdsOnly: consentStatus !== UMP.CONSENT_STATUS.OBTAINED,
videoOptions: {
muted: false,
},
expirationPeriod: 3600000, // in milliseconds (optional)
mediationEnabled: false,
});
console.log('Ads registered: ', result);
} catch (error) {
console.error('Error initializing ads:', error);
}
};
Any ideas to fix this? Thanks in advance
fixed it by commenting out this line
//requestNonPersonalizedAdsOnly: consentStatus !== UMP.CONSENT_STATUS.OBTAINED
Somehow it does not work properly on Android
closed
commenting out/removing requestNonPersonalizedAdsOnly doesn't fix the issue for me I still get the Could not invoke RNAdmobNativeAdsManager.registerRepository error. Do you have any ideas what else you might have done to solve it?