admob-plus: JIT compiler unavailable with target es2015 (Android)

First let me thank you for this plugin, it works really well. I’ve been using it for some time and I really like it.

I have an issue on Android when I try to use "target": "es2015" in my tsconfig.json: I get a white screen when I start the Android app and if I inspect the webview I see the error message “JIT compiler unavailable”.

If I set "target": "es5" in tsconfig.json, then everything works correctly!

Do you have any idea how to fix this issue?

I have created a small repo to reproduce the issue: https://github.com/francoisduchemin/ionic-admob-plus

I can reproduce this issue with the following steps:

  • Create starter ionic app: ionic start ionic-admob-plus tabs --type=angular --cordova
  • Add npm package for admob-plus: npm install @admob-plus/ionic
  • Add cordova plugin for admob-plus: ionic cordova plugin add admob-plus-cordova --variable APP_ID_ANDROID=ca-app-pub-3940256099942544~3347511713
  • Add <preference name="AndroidXEnabled" value="true" /> in config.xml
  • Add cordova plugin androidx-adapter: ionic cordova plugin add cordova-plugin-androidx-adapter
  • Build: ionic cordova build android --prod --release
  • Run: ionic cordova run android --prod

If I start the app in Android Studio, the app opens correctly in the emulator.

Now as soon as I add AdMob to the providers in app.module.ts, I get a white screen and the error JIT compiler unavailable:

import { AdMob } from '@admob-plus/ionic/ngx';

...

  providers: [
    AdMob, // <--- here
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],

The Chrome inspector then shows the following error message:

Could not find cordova.js script tag. Plugin loading may fail.
main.37aa675c04a56933b306.js:1 Error: JIT compiler unavailable
    at hn (main.37aa675c04a56933b306.js:1)
    at Function.get (main.37aa675c04a56933b306.js:1)
    at wt (main.37aa675c04a56933b306.js:1)
    at Ii (main.37aa675c04a56933b306.js:1)
    at main.37aa675c04a56933b306.js:1
    at ki.processProvider (main.37aa675c04a56933b306.js:1)
    at main.37aa675c04a56933b306.js:1
    at main.37aa675c04a56933b306.js:1
    at Array.forEach (<anonymous>)
    at gn (main.37aa675c04a56933b306.js:1)
main.37aa675c04a56933b306.js:1 Ionic Native: deviceready event fired after

If I modify the target in tsconfig.json to es5 and build, then the app opens correctly! (no white screen)

Do you know if there is a way to target es2015? What am I doing wrong?

About this issue

Most upvoted comments

@itsLucario’s solution worked for me but the zip is old and the NativeAd is not included. I tried to build the lib using ngc without luck. @admob-plus/ionic is just a wrapper around the cordova version. I managed to resolve the JIT compiler issues by copying this file https://github.com/admob-plus/admob-plus/blob/master/packages/ionic/src/ngx/index.ts inside my project in a file named admob.module.ts (the name is not important). Then I changed the imports from @admob-plus/ionic/ngx to ./admob.module.ts and it seems to be ok.

Two remarks:

I’m still looking for a solution, this issue prevents me from updating my apps. If anyone has a solution, please share!

same problem any update ?

I made the current update:

@admob-plus/ionic: 1.7.0
admob-plus-cordova: 1.28
Error: The injectable 'AdMob' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.

JIT compilation is discouraged for production use-cases! Consider using AOT mode instead.
Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server',
or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping.

It looks like the problem persists with Angular 12, but it looks working with Angular 11 or 14. At least for me.

ok. For now, I have removed this plugin and using Admob Cordova plugin directly in my code. That seems to do the job and I dont have any white screen issues. So uninstalling admob-plus ionic plugin and editing the code accordingly seems to fix it. Hope there is a fix in this plugin so I can add this in the future version of my app updates.

@Mr-Anonymous Try running npm install admob-plus-ionic-0.0.1.tgz --legacy-peer-deps

admob-plus-ionic-0.0.1.zip

  • run npm uninstall @admob-plus/ionic
  • Download the give package which I created using ngc compiler.
  • Change the file extension from .zip to .tgz
  • run npm install <tgz file>

And you should have the plugin working.

I found a solution. I compiled the library with ngc and it works perfectly fine. Let me know if anybody needs help. I’ll publish and post instructions in my fork.

@ratson Any help or info would be appreciated.

I just updated one of my apps to ionic 6 and angular 13 and now my workaround (target ES5) is not working anymore… I get a white screen when running ionic cordova run android --prod with the error message Error: JIT compiler unavailable.

Does someone know another workaround?