Description
Right now when appropriate NDK is not installed the build will fail with
Target native_assets failed: Error: Android NDK Clang could not be found.
IIRC gradle will install ndk automatically for externalNativeBuild
projects. We do the same thing in cargokit (glue used to build rust code for Flutter plugins). That results in a smoother experience compared to failing the build. I'm currently looking into reimplementing cargokit in terms of native assets and this would be a bit of a downgrade.
This does raise question whether running build should be allowed to install NDK (or other toolchains for that matter). At least for gradle/NDK nobody seems to object.
Longer term it would be nice to have an option to install toolchains as part of build. When user has rustup
installed, cargokit will currently install missing toolchains and targets. But this means that build is modifying files outside of build folder (or pub cache). Which does feels a little bit iffy. It would be great if a hypothetical native_toolchain_rust
could install and manage rust toolchain, possibly stored in .pub_cache
so that it can get reused between project. Or maybe this could be done during pub get
through a hook, but at that point we don't know the target architecture so for rust for example we'd need to install all targets, which might be an overkill.