当我试图重建我的项目时,我会得到以下错误:
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
等等,但都没有用。
谢谢你的帮助。
发布于 2020-07-26 11:37:42
这可能是因为您自添加字段以来还没有进行构建,在Gradle文件中声明的BuildConfig
和其他变量/属性只有在成功构建之后才是可用的。以下说明将解决这一问题:
Build -> Clean Project
Build -> Rebuild Project
(现在注释导致编译器错误的任何行!)BuildConfig
上的Alt + Enter (Windows/Linux) or Option + Enter (macOS)
,然后从建议的解决方案中选择Import...
。发布于 2021-02-15 16:07:34
你只需要简单地点击build就可以构建你的应用程序。用禁食的方式来解决它。
发布于 2021-09-21 17:25:47
在我清理和重建项目之后,仍然面临着这个问题。
对我来说,这是gradle文件的错误:S,在您的buildType中检查是否存在错误。
buildTypes {
deubg { <- it should be "debug"
buildConfigField "String", "URL_BASE_DEBUG", '"https://example.example.com"'
buildConfigField "String", "TOKEN_DEBUG", '"********"'
buildConfigField "....."}
release {
buildConfigField "String", "URL_BASE_PROD", '"https://example.example.com"'
buildConfigField "String", "TOKEN_¨PROD", '"********"'
buildConfigField "....."}
https://stackoverflow.com/questions/59120296
复制相似问题