same here for my ionic 5 project.
Cannot connect from android simulator or on android device: i.e. 1st backend API call (for signin in my app) does not connect. It works fine with iOS.
Tried Remote Debugging Webviews and saw below error despite HTTP response is 200/ok
full stack
"SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at XMLHttpRequest.onLoad (http://localhost/vendor-es2015.js:10132:51)
at ZoneDelegate.invokeTask (http://localhost/polyfills-es2015.js:3741:31)
at Object.onInvokeTask (http://localhost/vendor-es2015.js:73280:33)
at ZoneDelegate.invokeTask (http://localhost/polyfills-es2015.js:3740:60)
at Zone.runTask (http://localhost/polyfills-es2015.js:3518:47)
at ZoneTask.invokeTask [as invoke] (http://localhost/polyfills-es2015.js:3815:34)
at invokeTask (http://localhost/polyfills-es2015.js:4953:14)
at XMLHttpRequest.globalZoneAwareCallback (http://localhost/polyfills-es2015.js:4990:21)"
In network tab the request is fine
{email: "john.doe@provider.com", password: "xyz123"}
but the answer is curiously not json, it is a capacitor code:
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript">window.Capacitor = { DEBUG: true };
//# sourceURL=capacitor-runtime.js
(function(win) {
win.Capacitor = win.Capacitor || {
Plugins: {}
};
Note breakpoints are never hit but I can see the webview. I build with ionic build
then
if ionic capacitor run android --livereload
: connection error on simulator and device.
if
npx cap sync android
, deployment ok, I can inspect in webview but breakpoints are not hit