android – How do I setup java code completion for a react native project on intellij?-ThrowExceptions

Exception or error:

React-native organizes its project like :

android
--build.gradle
--settings.gradle
ios
node_modules
index.android.js
index.ios.js

It’s a little messy and requires editing js, java and objective c code, and the android studio does not support any javascript code completion. So I decided to use IntelliJ.

The problem is that if I open up at the root level, IntelliJ can’t run Gradle, it will say Error running build (1): Module 'ReactLearning' is not backed by gradle

However, if I open up at ./android in either android studio or IntelliJ, it works fine and I can see all the external libraries and code completion. But now I can’t edit any of the code at the root level. I could have 2 editors open one at the root and one specifically for android, but then the IDEs are constantly overwriting each other’s files.

Is there something I can do to tell the IDE/ Gradle that the relevant project is one subdirectory down?

How to solve:

When you create a React Native project, an Android project is created inside its file tree:

enter image description here

Now, you can open the Android project using IntelliJ Idea or Android studio, with the path:

/path/to/untitled/android

And the untitled project which has been created with react-native init using WebStorm, which has JS support, with the path:

/path/to/untitled

Leave a Reply

Your email address will not be published. Required fields are marked *