Quasar: [Capacitor] TypeError: Cannot read property 'data' of undefined

Created on 22 Aug 2020  路  5Comments  路  Source: quasarframework/quasar

Describe the bug
image

This happens the second time when I build the app. It seems something goes wrong with the rebuild command?

The only workaround is to remove the src-capacitor and start over.

Codepen/jsFiddle/Codesandbox (required)
Codepen is going to be difficult for mobile. It does work fine when simple running it from a browser (SPA).

To Reproduce
Steps to reproduce the behavior:

  1. cd project/src-capacitor
  2. quasar build -m capacitor -T android --ide
  3. Install apk to device
  4. See error

The APK doesn't install at all when running without --ide. Also it doesn't open Android Studio, I need to open it manually.

Expected behavior
Build without the vendor error.

Screenshots
See Describe the bug

Platform (please complete the following information):
OS: Arch Linux
Node: v14.8.0
NPM: 6.14.7
Yarn: N/A
Browsers: Brave
iOS: N/A
Android: S9 - Android 10
Electron: N/A

Additional context
No build errors, only when running.

bug

All 5 comments

Hi,

  1. js/24.js is a devland chunk. That's the place where the error is reported.
  2. Android Studio is opened only if its executable is part of your PATH, otherwise there's no way that Quasar can detect where it actually lies.
  3. Doesn't makes any sense for a rebuild to break something.

Can you try to "quasar build -m capacitor -d" (-d is for debug) and check the log again to see where the error actually happens pls? If error is not from devland (don't think so by looking at the reported chunk) then is it possible for you to offer a reproducing repo (or upload a zip here -- without node_modules in it)?

I managed to solve the issue and it was indeed my own fault. :+1:

First I did incorrect API-response message failure handling: e.response.data.message
The object doesn't exists when the API call fails/timeouts/etc. In this case an invalid API URL was given.

When I want to make calls to my REST API on an Android emulator, I need to use my local IP address as API_URL, e.g. API_URL=http://192.168.1.100:8000/api/v1

When I'm deploying my app to my phone, the SSL certificate is incorrect and that blocks the API-call as well. So I need to generate an user trusted certificate for this as well.

Thanks for looking in to the issue, it's my first experience developing mobile apps, hope it helps others as well. :)

@rstoenescu Just one final question: do you need to keep the android folder: https://github.com/francoism90/mediadb-ui/tree/feat-capacitor/src-capacitor

Cordova looks a lot better: https://github.com/francoism90/mediadb-ui/tree/feat-capacitor/src-cordova

Yes, you need it. It's the actual native app that wraps everything for Android. When building for iOS, an ios folder will also appear there. Same goes for Cordova too. But you first need to dev/build for that platform in order for those folders to show up. I recommend sticking with Capacitor for a whole lot of reasons.

@rstoenescu Thanks for the information. :)

So far my experience with Capacitor have been mixed. It doesn't seem to allow external API calls, even when setting the correct URL's in allowNavigation as server option. It also seems to cause some weird rendering issues when actually deploying the app to my device. Cordova works fine, however if I'm not mistaken Capacitor should be a better alternative as it is open-source?

Was this page helpful?
0 / 5 - 0 ratings