Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unresolved reference BuildConfig

When i'm try to rebuild my project i get the error below:

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

When I check the class there're no unresolved references.

I'm using Gradle Version 3.3.1

I almost tried everything such as Invalidate Cache / Restart, Clean and Rebuild, Close and Reopen project, Reimport project, delete idea folder etc but none of them worked.

Thanks for your help.

like image 681
savepopulation Avatar asked Nov 30 '19 21:11

savepopulation


1 Answers

It's probably because you have not made a build since adding the field, BuildConfig and other variables/properties declared in a Gradle file will only be available AFTER a successful build. The following instructions will fix this:

  • Build -> Clean Project
  • Build -> Rebuild Project (comment any lines that cause compiler errors for now!)
  • Press Alt + Enter (Windows/Linux) or Option + Enter (macOS) on BuildConfig in your code and select Import... from suggested solutions.
like image 123
HumbleBee Avatar answered Sep 18 '22 15:09

HumbleBee