Reputation: 201
I opened a project that I had not opened in a while in Eclipse today. I was unable to compile due to some (inexplicable) errors.
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.view.animation.Animation;
import android.content.Intent;
produces the following error:
the import android could not be resolved
What can I do to resolve this problem?
Upvotes: 16
Views: 45378
Reputation: 23
So none of the other solutions worked for me but I found another way that worked for me.
Right click on the project -> go to properties ->Java Build Path -> Libraries -> Add External JARs
YOUR_DRIVE\android-sdks\platforms\android-??
add android.jar file
Upvotes: 0
Reputation: 3330
This is an updated answer for if you're using Android Studio. You may run into this problem due to how it caches.
In the event that you get this error with any package it's a good idea to go to File -> Invalidate Cache/Restart and select to drop the cache.
This can also fix issues that sometimes might persist between reinstalls due to the fact that upon uninstall Android Studio does not delete the cache.
Upvotes: 2
Reputation: 7386
In my case, I Need to go to Properties > Java Build Path > Order and Export
After checking the Android 4.0 Library ( may be different version in your case) it started working
Upvotes: 0
Reputation: 264
Also Make sure that, the current application and imported libraries/applications are having the same android API versions... (14, 15, 17, etc)... The mismatch of API version also will cause the same issue.
Upvotes: 1
Reputation: 95
Well, I also ran into that problem when I imported an existing Android project from a friend into my workspace. I found that I was missing JRE library but also Android library (Android Classpath Container library). You can add it like this:
Good luck!
Upvotes: 4
Reputation: 18980
Try one of these:
‘Clean’ Your Eclipse Project: Go to Project > Clean in Eclipse [This seems to work for me]
Refresh your project folder (right click on your project > refresh) Re-build your project
Clean your builds (If using Ant or Maven – clean your builds) Recreate your project in Eclipse
‘Switch’ Workspace – then Switch back (Eg Change to Debug, then switch back to Java)
‘Switch’ Workspace – then Switch back (Eg Change to Debug, then switch back to Java)
Remove and re-add your JRE:
Upvotes: 9
Reputation: 3949
First try clean / build your project.
If the problem persists. Right click on the project -> go to properties -> go to android -> select the android version and that should work.
Hope it helps.
Upvotes: 43