profound_swami
profound_swami

Reputation: 133

Android Studio: Error resolved after restarting. Nothing wrong with code. Why?

   View v = inflater.inflate(R.layout.fragment_car_list, container, false);
   mCarRecyclerView = (RecyclerView) v.findViewById(R.id.car_recycler_view); 

Android Studio was throwing an error Cannot resolve symbol 'car_recycler_view'. I spent almost an hour trying to figure out what was causing it and could not find a solution. Then, I remember reading that restarting Android Studio may sometime resolve issues. So, I restarted Android Studio and the error was gone. So it seems like nothing was wrong with my code.

Why is Android Studio given me the error? Why did the error go away after restarting?

Upvotes: 1

Views: 131

Answers (2)

Abhinav Chauhan
Abhinav Chauhan

Reputation: 1384

actually pop up is not a compiler feature compilers very rarely have bugs , so android studio indexs all your class, method, varibles and collects information about them to show you the pop up. It is also written bottom as indexing sometimes in android studio , somehow in your case it couldn't index it , or accidently you stopped the process , so it did know that the variable exits. Code still compiles because compiler is a different software it does not care how android studio works , so it still compiles.

So there was some exception while indexing your code which android studio couldn't recover or it is a bug.

when you apply the solution from MohammadMoeinGolchi the indexing happens again and android studio forgets the information it had previously about the project and collects the information again and this time chances are it will see your variable.

Upvotes: 0

MMG
MMG

Reputation: 3268

Sometimes you need to clean project and rebuild it. It may solve your problem.

enter image description here

Upvotes: 1

Related Questions