question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Capacitor platform detection works wrong if html and js stored in Filesystem

See original GitHub issue

Bug Report

I save html and js to Filesystem (html and bundled js with Capacitor dependency included), then I use location.replace('Capacitor.convertFileSrc('some_file_url.html')). Everything works as expected, no errors. But after location replace to on Android platform is not detected correctly. I tried different capacitor.config.json options to fix this, but no success yet. Looks like WebView restricts something when using local files.

Capacitor Version

💊   Capacitor Doctor  💊

Latest Dependencies:

  @capacitor/cli: 2.4.7
  @capacitor/core: 2.4.7
  @capacitor/android: 2.4.7
  @capacitor/electron: 2.4.7
  @capacitor/ios: 2.4.7

Installed Dependencies:

  @capacitor/cli 2.4.7
  @capacitor/core 2.4.7
  @capacitor/ios 2.4.7
  @capacitor/android 2.4.7
  @capacitor/electron not installed

[success] Android looking great! 👌
  Found 1 Capacitor plugin for ios:
    capacitor-secure-storage-plugin (0.5.0)
[success] iOS looking great! 👌

Platform(s)

Android 9.x, but i believe any other version works too

Current Behavior

Capacitor.platform === 'web' and Capacitor.isNative === false

Expected Behavior

Capacitor.platform === 'android' and Capacitor.isNative === true

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jcesarmobilecommented, Mar 12, 2021

I can’t reproduce.

A few points:

0reactions
ionitron-bot[bot]commented, Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FileReader API not firing · Issue #1564 · ionic-team/capacitor
When building my project using Cordova, the FileReader fires ... If we take zone.js (angular/ionic) out of the equation it works fine.
Read more >
Capacitor Filesystem returns error while using main functions
When using Android 11 to create a directory using the mkdir() function I get the following error: Unable to create directory, unknow reason....
Read more >
Filesystem.mkdir not working right in Android Emulator
When my app initializes I check to see if the main storage folders need to be created, and create them if needed.
Read more >
The Ionic Image Guide with Capacitor (Capture, Store & Upload)
Capturing, storing and uploading image files with Ionic is a crucial task inside many applications, even if it's just a small avatar of...
Read more >
How to Download and Open Files with Capacitor & Ionic [v5]
Learn how to download any file from the web and open them from your device using Capacitor ! Learn Ionic faster...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found