I’m working on a very old legacy app that is on the way of getting replaced with a modern solution, but that should work as intended for the remaining time until this new solution is finished.
This Xamarin app uses Web views to render some data, and more precisely, it builds a webview inside the app using a solution very similar to the one described in this tutorial.
There is a few steps to build such a webview, starting from a script building method that will progressively add some script tags inside of the webview. Some of those tags implies that they will need to trigger CS methods from the JS code via Invoke methods.
Before I ever started working on the app, this system was working just fine, and was able to trigger CS methods from within the JS scripts of the webview, via a Export tag above the said methods.
My job was to make the app usable on Android 12 and above, as it was targeting mostly android 6 and 4.4 in the multiple subprojects of the solution, with a MinTargetVersion targeting android 2.3. And this was the parameter that needed to change to make it installable on modern devices (with a bit of extra work on some methods, like permissions for example).
But when I change the MinTargetVersion, it can indeed run even on Android 14, but every single webview using script injection that should trigger CS methods completely stopped working, with this kind of errors :
"Uncaught TypeError: JS2CS.CallCS is not a function", source: file:///android_res/ (1)
I tested with a way simpler webview, just loading a bit of text and css, and everything works properly, it’s really just when calling external methods. There’s no warnings, no deprecation on any part of the involved code, and I just can’t understand why changing the MinTargetVersion only makes such a difference.