1. 程式人生 > >【我的Android進階之旅】解決編譯出現錯誤:Error: In DataSet 'main', no data file for changedFile.

【我的Android進階之旅】解決編譯出現錯誤:Error: In DataSet 'main', no data file for changedFile.

一、問題描述

晚上在Android Studio上,切換分支之後,重新編譯執行的時候,報錯了,錯誤資訊如下所示: 在這裡插入圖片描述

錯誤資訊文字:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':p_imphone:packageDebugResources'.
> D:\GitLab Source\XTCWatch_TalentAccount\XTCWatch\p_imphone\src\main\res\values\strings.xml: Error: In DataSet 'main', no data file for changedFile. This is an internal error in the incremental builds code; to work around it, try doing a full clean build.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 27s
74 actionable tasks: 30 executed, 44 up-to-date

二、解決錯誤

如上所示,提示我們要想編譯成功,得先來一遍完全的clean,因為切換分支之前,有其他分支編譯的產物影響了切換分支之後的編譯。

Error: In DataSet ‘main’, no data file for changedFile. This is an internal error in the incremental builds code; to work around it, try doing a full clean build.

  • 執行 gradlew clean 命令 在這裡插入圖片描述

  • 重新編譯 clean成功之後,再次編譯的話就成功了,如下所示:

在這裡插入圖片描述