Ionic-wkwebview: Android build doesn't load any local templates

Hi, I am in the process of migrating my v1 app to wkwebview from UIWebView. Now that apple has officially stuck a deprecated sign on UIWebView, I decided to act.

So far, iOS works well.

On Android, it builds fine but when I deploy to a device, it can’t seem to load any local templates. I’m probably missing something simple. Any thoughts? (removing ionic-webview before building android works just fine)

Android Device OS: 7.0


<meta http-equiv="Content-Security-Policy" content="img-src * blob: android-webview-video-poster: cdvphotolibrary:  'self' data: ws: wss://*; default-src * blob: 'self' gap: wss: ws: data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src * http: https: ws: wss:;">

My allow-navigation :

<allow-navigation href="http://localhost:8080/*" />

ionic info: (I know its not the latest, but unless you are sure it will solve this issue I’m reporting, please don’t ask me to update )

 ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0
    Gulp CLI              : CLI version 3.9.1 Local version 3.9.1

local packages:

    Cordova Platforms : android 6.4.0 ios 4.5.5
    Ionic Framework   : ionic1 1.3.5


    Android SDK Tools : 26.1.1
    ios-deploy        : 2.0.0
    Node              : v6.11.2
    npm               : 3.10.10
    OS                : macOS High Sierra
    Xcode             : Xcode 10.0 Build version 10A255

I am on the latest wkwebview plugin: cordova-plugin-ionic-webview 2.1.4 "cordova-plugin-ionic-webview"

(cross posted on SO)

Well, so I narrowed it down. Don’t yet know what is going on, but I do know what is causing it.

  • I use cordova-certificate-plugin to enable my app to work with servers that use self-signed certificates.
  • The plugin has a method called cordova.plugins.certificates.trustUnsecureCerts(true); which enables this functionality.
  • If I use cordova-plugin-ionic-wkwebview and invoke this method, stuff breaks in my app, including loading local templates

Now here is the confusing part. I thought ionic-plugin-wkwebview would only affect iOS builds. Why is adding this plugin messing up my android build when android doesn’t use wkwebview? Looking at its code, it does mess with Android as well, so investigation continues.

*SMH *

hey @pliablepixels, have you been able to migrate to WKWebView fully? I’m just gonna start this task, and threads like this are very helpful - thank you for them! If you have any other insights or sources you found useful, I’d appreciate it, though I understand you were doing this already a year ago :slight_smile:

I did not get WKWebview working in Android, especially since I use self-signed certs. So I remove this plugin for android. My code is open - here. My android build script. Best of luck!

1 Like