Android Studio Canary版本创建C++游戏活动项目时遭遇NativeSourceRootType未注册为JpsModelSerializerExtension错误求助
Hey there, sorry you're stuck with this super obscure error—total bummer when Google turns up nothing! Let's walk through what's going on and how to fix it.
First, let's break down what JpsModelSerializerExtension is: it's an internal component in IntelliJ/Android Studio that handles serializing your project's configuration (like mapping out where your NDK/C++ source files live) into a format the IDE can read and load properly. The error you're seeing means the extension responsible for recognizing NDK source root directories didn't register correctly with the IDE—this is almost certainly a bug or compatibility quirk in the Canary (pre-release) version of Android Studio you're using, since those builds are still in testing and often have rough edges.
Here are some actionable steps to try fixing this:
Clean cache and resync your project first
This is the go-to fix for most IDE weirdness. Go toFile→Invalidate Caches..., selectInvalidate and Restart, and let the IDE reboot. Once it's back up, clickFile→Sync Project with Gradle Filesto refresh your project configuration.Verify your NDK/CMake setup
Open your project'slocal.propertiesfile and make sure thendk.dirandcmake.dirpaths point to the versions bundled with your Canary Studio (avoid using standalone/old versions of NDK here). For example:ndk.dir=/Users/YourUsername/Library/Android/sdk/ndk/26.1.10909125 cmake.dir=/Users/YourUsername/Library/Android/sdk/cmake/3.22.1If the paths are wrong, update them to match the versions you have installed via the SDK Manager (
Tools→SDK Manager→SDK Toolstab).Downgrade your NDK version
Canary builds sometimes have trouble with the latest NDK releases. Head to the SDK Manager, uncheck your current NDK, pick a stable older version (like 25.x series), install it, then update thendk.dirinlocal.propertiesto point to this new version and resync.Double-check your module's build.gradle config
Open your module-levelbuild.gradlefile (not the root one) and confirm theexternalNativeBuildblock is set up correctly, with a CMake version that matches what you have installed:externalNativeBuild { cmake { path "src/main/cpp/CMakeLists.txt" version "3.22.1" } }If all else fails, switch to a stable Android Studio build
Canary builds are great for testing new features, but they're not always reliable for day-to-day work. If you need to get your project up and running quickly, download a stable release (like Giraffe or Hedgehog), import your project, and it should build without this error.
Hopefully one of these steps gets your project building smoothly!
备注:内容来源于stack exchange,提问作者ayuumu nyasu

