Problems with importing Android platform classes

2019-02-16 11:57发布

问题:

I'm new to Android. It seems there have been way too many problems just getting eclipse and the SDK setup with everything just where it should be. I've been working on an example from the Android Developer website, but it's throwing an error saying:

The import android.support cannot be resolved

I'm trying to import the following:

import android.support.v4.app.NavUtils;

I have three of the newest SDK platform versions installed and also have the rev.10 support library installed. Is the android.jar file pointing to the wrong folder? I found the folder/files that I'm trying to import but I'm wondering if they're in the right place.

C:\Program Files (x86)\Android\android-sdk\sources\android-16\android\support

I haven't moved anything since I installed everything, so I'm confused why most everything else will import but the support classes are missing. Thanks in advance for the help.

回答1:

but it's throwing me an error saying "The import android.support cannot be resolved"

Everything in the android.support.* series of packages comes from the Android Support package (what I think you are calling "rev. 10 support library".

I have three of the newest SDK platform versions installed and have rev.10 support library installed

The Android Support package does not only need to be downloaded to your development machine, but it also needs to be added to your project. If you are using Eclipse, right-click over your project in the Package Explorer and choose Android Tools > Add Support Library to add it to your project. If you are not using Eclipse, find the android-support-v4.jar file in your SDK installation and copy that to your project's libs/ directory.