Blog

  • πŸ’₯ Fixing Kotlin Daemon Errors During Flutter AAB Build

    While preparing to publish a Flutter app to Google Play, I encountered a strange error during the flutter build appbundle process.

    
    Daemon compilation failed: null
    java.lang.Exception ...
    Caused by: java.lang.Exception: Could not close incremental caches ...
    IllegalArgumentException: this and base files have different roots:
    e.g., C:\path\to\pub_cache\shared_preferences_android vs D:\path\to\project
    

    This error typically occurs when the Kotlin Incremental Compiler fails to resolve relative paths between files located on different drives (C:\ and D:\, for example).

    🧩 Root Cause

    • Incremental cache close failure: Kotlin cache couldn’t be closed properly
    • IllegalArgumentException: Relative path resolution failed due to files being on different drive roots

    πŸ›  How I Fixed It

    βœ… 1. Run flutter clean

    In most Flutter projects, flutter clean is the first go-to command to reset build caches:

    
    flutter clean
    flutter pub get
    flutter build appbundle
    

    βœ… 2. Stop Gradle Daemon & Delete Caches (if needed)

    If the issue persists, stop the Gradle daemon and manually delete cached data:

    
    gradlew --stop
    

    Recommended cache paths to delete:

    • C:\Users\YourUsername\.gradle
    • C:\Users\YourUsername\AppData\Local\Pub\Cache
    ⚠️ Deleting these may require re-downloading dependencies on the next build, which can take time.

    βœ… 3. Reinstall Problematic Packages

    If a specific package (e.g., shared_preferences) is causing issues, try reinstalling it:

    
    flutter pub remove shared_preferences
    flutter pub add shared_preferences
    

    🎯 Result

    After following the above steps, the build completed successfully and the AAB file was generated without any issues.

    πŸ”š Final Thoughts

    Most Flutter build errors come down to corrupted caches or path conflicts. When in doubt, start with flutter clean β€” it just might save you hours of debugging.

  • Technology for a Future

    We believe technology is more than a toolβ€”
    it’s a bridge between people and possibility.

    At LIMFEET,
    we design the future through AI, IoT,
    and intelligent automation.

    Not just progress,
    but purpose-driven innovation.
    We build tomorrow, starting today.