Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve symbol 'build' on line import com.android.build.OutputFile in app/build.gradle

So I just created a react native project using the command

react-native init "project-name"

I went into the app level build.gradle to connect firebase and I had an error saying could not resolve symbol 'android' on the line

import com.android.build.OutputFile

However, it popped up saying "android framework is detected in the project click to configure" so I did this, but then it said cannot resolve symbol 'build' on the same line, I have no idea why it's saying this as I have made the project the same way before and never had this problem, any ideas?

like image 509
Dfarrelly Avatar asked Oct 03 '16 22:10

Dfarrelly


People also ask

Can not resolved symbol?

Most often “R cannot be resolved” error appears if there is an issue with some of your resource files. Due to this error, you are unable to build your application. That's why we need to solve this error as it not getting away by just doing a simple restart or hitting Alt+Enter.

How do I sync gradle with Android studio?

Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.


3 Answers

In my case I was able to solve this by following those steps:

  1. Comment out the line like this: // import com.android.build.OutputFile
  2. Sync the project (click "Sync now")
  3. Comment in the line again like this: import com.android.build.OutputFile
  4. Sync again.

This might not work for everybody. In my case said import worked until I changed something somewhere in the project and suddenly the import failed. If the import never worked for you, this might not be the solution, but otherwise worth a try.

like image 181
Nick Avatar answered Oct 12 '22 10:10

Nick


the thing that worked for me was

1- replace this line in build.gradle(:app)

def abi = output.getFilter(OutputFile.ABI)

with:

def abi = output.getFilter(com.android.build.OutputFile.ABI)

2- and click on sync project with gradle files (the elephant with blue arrow)

enter image description here

like image 22
shiraz27 Avatar answered Oct 12 '22 10:10

shiraz27


Try double click on build word in your code such as Build.VERSION, not in the import com.android.build.OutputFile. then if it show press ALT + Enter, you should do it.

like image 32
Pangeran Zuckerberg Avatar answered Oct 12 '22 09:10

Pangeran Zuckerberg