Skip to content

Instantly share code, notes, and snippets.

@shaxxx shaxxx/crosswalk
Last active Feb 26, 2019

Embed
What would you like to do?
Crosswalk + Ionic4
//star blank Ionic project
ionic start walk sidemenu --type=angular
//change to Ionic project folder
cd walk
//add android platform
ionic cordova platform add android
//remove Ionic webview
ionic cordova plugin remove cordova-plugin-ionic-webview
//add crosswalk webview
ionic cordova plugin add cordova-plugin-crosswalk-webview
//add plugin to fix crosswalk build error due to gradle error
ionic cordova plugin add cordova-android-support-gradle-release
//modify src/index.html and change
<base href="/" />
//to
<base href="/android_asset/www/" />
//modify src/main.ts to fix "URL scheme "file" is not supported." when loading SVG assets
//https://github.com/ionic-team/ionicons/issues/572#issuecomment-402895894
//add
function androidFetchWorkaround() {
const originalFetch = (window as any).fetch;
(window as any).fetch = (...args) => {
const [url] = args;
if (typeof url === 'string' && url.match(/\.svg/)) {
return new Promise((resolve, reject) => {
const req = new XMLHttpRequest();
req.open('GET', url, true);
req.addEventListener('load', () => {
resolve({ ok: true, text: () => Promise.resolve(req.responseText) });
});
req.addEventListener('error', reject);
req.send();
});
} else {
return originalFetch(...args);
}
};
}
androidFetchWorkaround();
//above
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));
//run on android
ionic cordova run android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.