MobileBlazorBindings
MobileBlazorBindings copied to clipboard
Android Hybrid: Loading local js/css results in "Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME"
I can't for the life of me figure out this issue.
I am trying to load local JS/CSS files in a MBB Hybrid Android app using <link? and
This is with 0.5.50-preview. Code can be found on this specific branch https://github.com/Kukks/chaincase/tree/rcl
Hi @Kukks I am unable to run that project. I tried on both iOS and Android and it simply wouldn't load. Can you provide any more info about the error? Maybe use Chrome debugging tools to see what the URL was that failed? Or catch all .NET CLR exceptions while running under a debugger?
@Eilon what do you mean by it won't load? I'm just getting a white screen but the html is available to me in the iOS debugging tools. Using the debugging tools it's showing me the problem is ionic.esm.js, ionic.bundle.css, and ionic.js in index.html
<script type="module" src="_content/Chaincase.UI/ionic/ionic.esm.js"></script>
<link rel="stylesheet" href="_content/Chaincase.UI/ionic/ionic.bundle.css">
<script nomodule="" src="_content/Chaincase.UI/ionic/ionic.js"></script>
are nowhere to be found. They're making it into the Chaincase.UI project's wwwroot folder but aren't available at the platform specific _content/Chaincase.UI route unlike https://github.com/kukks/hara which works fine and seems to be the same strategy almost exactly. When the module and stylesheet in question are removed, the plain html loads up.
in debugger under Sources By Path There is no _content/Chaincase.UI folder at all despite a wwwroot folder existing in the Chaincase.UI project
Granted, we're trying to pull the js files from npm into the wwwroot folder BeforeBuild. It seems to work in that Hara solution but not here in iOS and Android, only in the SBB project
(@ a slightly changed HEAD to make iOS work https://github.com/chaincase-app/chaincase/tree/Kukks-rcl)
I'm not sure what the problem was but when I try to run it from VS, it would build the project, open the emulator, but then the app wasn't getting deployed. I can try again at some point.
It wouldn't be surprising if the problem is something to do with build ordering. Getting the MSBuild steps right is... not easy!
I will take another look at this.
getting closer ...
in a project where the app uses ionic successfully (Hara.iOS) the build output includes:
Target _CopyResourcesToBundle:
...
Copying file from '/Users/dan/f/chaincase/app/Hara.UI/wwwroot/ionic/p-f428a208.js' to '/Users/dan/f/chaincase/app/Hara.iOS/bin/iPhoneSimulator/Debug/device-builds/iphone 11-14.2/Hara.iOS.app/wwwroot/_content/Hara.UI/ionic/p-f428a208.js'
and all the other ionic files from UI's ionic folder to iOS bundle's ionic folder.
In the broken one (Chaincase.iOS) this isn't happening even though the wwwroot/ionic files exist in the Chaincase.UI project from npm install. Got to be a quirk with MSBuild. I haven't been able to spot the difference between the two yet but I'm still on it
We fixed this in msbuild and it can be closed. Thanks for the awesome bindings Eilon you're a beast.
@DanGould oh can you share more info about what the fix was? A fix in MSBuild itself, or in some CSPROJ? Any info you have might help me or others in the future. Thanks!