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?
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.
This means that you have tried to run a program that used some class that has not compiled correctly.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With