Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

ReactNative :app:compileDebugJavaWithJavac FAILED

I realise I've posted a few times now on React Native. I won't post a new repo on my latest issue (unless anyone asks for one) but I'm starting to lose faith that I can work with RN.

Until recently, I at least had RN working with my Android emulator but I was struggling with following along with the course... so I created a new branch and started following along from Section 2 of the React Native course again.

Since then I've been getting this error

C:\xampp\htdocs\reactProject\android\app\src\main\java\com\reactproject\MainApplication.java:19: error: cannot find symbol
      return BuildConfig.DEBUG;
             ^
  symbol: variable BuildConfig
1 error
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

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

BUILD FAILED

Total time: 1 mins 1.76 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

and cannot get the emulator to work; the NodeJS CLI simply shuts down. I know I have RN set up correctly. I've tried upgrading RN from the command line Any idea what I might be missing?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there Jonathan Grieve ! Sorry this is so frustrating. It seems like the problem might not be with RN at all, but rather with Android Studio. I may have found your answer, but I'm not sure yet. I was curious as it was trying to return something that didn't exist. So I did some poking around on your behalf. Apparently, when Android Studio is first installed it contains two "build variants". These are "debug" and "release". If you'll look on the lower left-hand corner of Android Studio you can see a tab there for "build variants".

However, it appears that neither one of these include BuildConfig.DEBUG. To have access to this, you have to set up a build variant yourself, and build it using that.

I found two resources which might be of interest and I hope they help:

BuildConfig missing

Configuring Build Variants

Let me know how it goes! :sparkles:

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Thanks Jennifer, :)

I'd still be very curious as to why it would work then so suddenly give me so much bother.

I'm trying to get my head around those links now. One thought I've just had is that I'm using an emulator from a completely different app so I can preview my RN project. Am I going about that the right way? Do I need an Android Studio project specifically for testing a React Native project. That part always confused me. :)