Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Intent cannot be resolved to a type' error in eclipse

I am programming the first android tutorial in eclipse, and when compiling this code:

Intent intent = getIntent();

it gives the error

Intent cannot be resolved to a type

How do I fix it?

like image 955
Joseph Dykstra Avatar asked Aug 03 '12 22:08

Joseph Dykstra


People also ask

What is the error of Cannot be resolved to a type?

This means that your project isn't setup to include the JUnit libraries when it compiles; JUnit is not included in the Java runtime libraries (JRE System Library) so you have to add it to the build path.

What does it mean when a class Cannot be resolved to a type?

This means that you have tried to run a program that used some class that has not compiled correctly.

Can not be resolved error in Java?

To fix the Java “cannot be resolved to a variable” error, you must declare the variable inside the scope where you will utilize it. The missing variable declaration is the most common cause of this error. That's why it is important to declare a variable before using it in the current scope.


1 Answers

Probably, the import statement is missing. Try pressing Ctrl+Shift+O, Eclipse will automatically add the import statement if missing.

Then look at the top of the file and see what has been added. It should be something like this:

import android.content.Intent;
like image 162
Yogu Avatar answered Oct 26 '22 18:10

Yogu