android - 未解决的参考 BuildConfig
问题描述
当我尝试重建我的项目时,出现以下错误:
warning: flag is not supported by this version of the compiler: -Xallow-no-source-files
warning: flag is not supported by this version of the compiler: -Xjava-source-roots=/Users/tyln/AndroidStudioProjects/PhoneBox/base/navigation/build/generated/source/buildConfig/dev/debug
base/navigation/src/main/java/com/raqun/phonebox/navigation/IntentLoader.kt:7:9: error: unresolved reference: BuildConfig
BuildConfig.PACKAGE_NAME,
^
> Task :base:navigation:compileDevDebugKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':base:navigation:compileDevDebugKotlin'.
> Compilation error. See log for more details
当我检查课程时,没有未解决的引用。
我正在使用 Gradle 版本3.3.1
我几乎尝试了诸如此类的所有东西,Invalidate Cache / Restart, Clean and Rebuild, Close and Reopen project, Reimport project, delete idea folder
但没有一个起作用。
谢谢你的帮助。
解决方案
这可能是因为您在添加字段后尚未进行构建,并且在 Gradle 文件中声明的其他变量/属性只有在成功构建之后BuildConfig
才可用。以下说明将解决此问题:
Build -> Clean Project
Build -> Rebuild Project
(现在评论任何导致编译器错误的行!)Alt + Enter (Windows/Linux) or Option + Enter (macOS)
在BuildConfig
您的代码中按下并Import...
从建议的解决方案中进行选择。
推荐阅读
- mysql - MySql 相当于 MS 访问 DatePart
- c# - C#命名空间问题:必须避免命名空间包含任何类名重叠?
- google-cloud-platform - GCP 对来自同一区域的存储桶的调用收费?
- asp.net-mvc - 使用asp.net mvc将表对象从视图传递到控制器
- swift - Firebase 数据和意外的 nil
- .htaccess - 如何将我的 sudomains 网络空间重定向到实际的子域?
- assembly - 如何使用 llvm/clang 构建(或移植?)MASM ASM 文件?
- java - Array/ArrayList 如何直接指向对象的索引?或者 ArrayList 如何知道对象存储在这个地方?
- java - 来自 subscribeToStreamingNotifications 的带有 Item.bind() 的 AccessDenied
- c# - 如何使用 newtonsoft JSON 反序列化器反序列化 Geopoint?