Android 未解析的引用BuildConfig

Android 未解析的引用BuildConfig,android,android-studio,Android,Android Studio,当我试图重建我的项目时,出现以下错误: 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

当我试图重建我的项目时,出现以下错误:

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

我几乎尝试了所有方法,比如
使缓存无效/重新启动、清理并重建、关闭并重新打开项目、重新导入项目、删除idea文件夹等,但都没有成功


感谢您的帮助。

这可能是因为您在添加字段后还没有进行生成,
BuildConfig
和Gradle文件中声明的其他变量/属性只有在成功生成后才可用。以下说明将解决此问题:

  • Build->Clean项目
  • Build->Rebuild Project
    (暂时注释导致编译器错误的所有行!)
  • 在代码中按
    BuildConfig
    上的
    Alt+Enter(Windows/Linux)或Option+Enter(macOS)
    ,然后从建议的解决方案中选择
    Import…

只需单击build APK即可构建应用程序。禁食是解决问题的方法


你找到解决办法了吗?没有。我没有|只要运行代码就解决了我的问题。我尝试了所有可能的解决方案,但都不起作用。但是谢谢你的回答。