react-native-admob-native-ads icon indicating copy to clipboard operation
react-native-admob-native-ads copied to clipboard

Ads repo feature results in invalid template ID error in release mode

Open markchen8717 opened this issue 3 years ago • 14 comments

I am using the Ad repository feature #216 from the master branch on an Android device (Real device, not emulator). I am able to load ads (real non-test ads) in debug mode perfectly. However, once in release mode, no ads are loaded, and results in the error "[AD] [FAILED]: Invalid template ID: -1". Any help from @Ali72 @ammarahm-ed would be greatly appreciated. Please let me know if any additional information is needed. Thanks in advance!

index.js

https://gist.github.com/markchen8717/db20be57ab139c69805c8d3509dc98c4

AdView.js

https://gist.github.com/markchen8717/1172cbfb000c2c5cb617222be8a4d325

markchen8717 avatar Dec 27 '21 18:12 markchen8717

Are your Ad IDs new? Did you get them recently from AdMob?

ammarahm-ed avatar Dec 27 '21 18:12 ammarahm-ed

Are your Ad IDs new? Did you get them recently from AdMob?

Hi ammarahm-ed, thanks for the swift reply. My Ad IDs are not new, I've had them for over a year already. Additionally, with the same IDs, the library is working in release mode without the AD repository feature (default on demand ad loading).

markchen8717 avatar Dec 27 '21 19:12 markchen8717

@markchen8717 try to use test ad ids in release mode and see if you get any ads then - [ ] or if there is any error thrown? Subscribe to onAdFailedToLoad prop

ammarahm-ed avatar Dec 27 '21 19:12 ammarahm-ed

@markchen8717 try to use test ad ids in release mode and see if you get any ads then - [ ] or if there is any error thrown? Subscribe to onAdFailedToLoad prop

@ammarahm-ed I tried to use test ad ids in release mode and its working without any errors. I am not sure if this means my Ad IDs are the issue here since they work without the Ad repo feature in release mode as well and works with the feature in debug mode too.

markchen8717 avatar Dec 27 '21 19:12 markchen8717

Hi @ammarahm-ed, I re-installed my node_modules to get the latest #239 PR. Running the app again with my Ad ids using the Ad repo feature in release now results in the error : "[AD] [FAILED]: Invalid template ID: -1". Can you please shed some light on this?

markchen8717 avatar Dec 28 '21 14:12 markchen8717

@Ali72 You are using the lib in production. Have you seen any such error? Any idea what might be causing this?

ammarahm-ed avatar Dec 29 '21 16:12 ammarahm-ed

We use this repo in our projects (android and IOS version) without facing this issue but please answer the below questions:@markchen8717

  1. What's your react-native version?
  2. Did make a release with disabled minify and proguard option? (if not, disable it and build your project in release state)

Ali72 avatar Dec 29 '21 18:12 Ali72

Hi @Ali72 , my react-native version is 0.64.2. I am not sure about whether I have disabled minify and proguard option. The following is my build.gradle buildtypes

buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

Please let me know how I can check and make the changes accordingly

markchen8717 avatar Dec 29 '21 19:12 markchen8717

@markchen8717 To check if proguard is enabled. See for def enableProguardInReleaseBuilds line in app/build.gradle

ammarahm-ed avatar Dec 29 '21 19:12 ammarahm-ed

@Ali72 and @ammarahm-ed, it appears that I have def enableProguardInReleaseBuilds = true. However, even after setting def enableProguardInReleaseBuilds = false and minifyEnabled false under buildTypes in `app/build.gradle, I am still getting the error in release mode.

markchen8717 avatar Dec 29 '21 20:12 markchen8717

Hi @Ali72 and @ammarahm-ed, I found this stackoverflow post with regards to the error. Do you guys have app-ads.txt setup for your ad mob account?

markchen8717 avatar Jan 06 '22 04:01 markchen8717

I seem to be having a very similar issue to this one. @markchen8717 did you ever get this figured out?

sethcwhiting avatar Jul 07 '22 15:07 sethcwhiting

Also having this issue with a lot of users

renatomserra avatar Jan 12 '23 01:01 renatomserra

@markchen8717 did you end up finding a solution?

renatomserra avatar Jun 18 '23 09:06 renatomserra