When working with Room and KSP (Kotlin Symbol Processing) for type converters in an Android project, I encountered a recurring issue after adding a new type converter. The error message was:
java.lang.IllegalStateException: Storage for [C:\...\symbolLookups\id-to-file.tab] is already registered
This issue appeared after introducing a new type converter for handling a list of strings (List<String>
) with Room. The app uses Kotlin Symbol Processing (KSP) to handle annotation processing for Room and type converters.
Whenever I added a new type converter, KSP's caching mechanism caused a conflict. The error prevented the project from compiling. The root cause seems to be related to how KSP handles the storage of symbol lookup files, which may not automatically clear when significant changes occur (such as adding new type converters).
Here’s how I resolved it:
Build -> Clean Project
option in Android Studio.File -> Invalidate Caches / Restart
../gradlew --stop
It seems to be related to how KSP manages its caches. When introducing new elements, such as type converters, KSP may not invalidate certain cached symbol lookup files automatically. This results in a conflict when it attempts to register new storage for these symbols. A clean, followed by cache invalidation and a system restart, forces the system to refresh these caches fully.
Has anyone else faced this problem when adding a new type converter in a Room with KSP? Are there any known permanent fixes or preventive steps beyond cache invalidation and restarting the machine?
I'd appreciate any insights or potential solutions, especially if there's a more reliable way to prevent this error. Feel free to share your experiences with similar KSP cache issues!
I don't know the final solution, but you can stop the gradle deamon:
./gradlew --stop
This command will kill the deamon and the next building will work. Unfortunately you have to do it every time, when it freezes...