Question

I've downloaded the source code of android widget "TextView". I included some other packages, but Eclipse can't find them. I've checked android source again and they exist there.

import android.content.UndoManager;
import android.text.GraphicsOperations;
import android.content.res.CompatibilityInfo;

So why doesn't Eclipse them? In source code they are also public.

I'm using Android 4.4.2.

Was it helpful?

Solution

If you are trying to build something that is part of AOSP and import it into eclipse, then you need to let eclipse know what those other packages are. Based on android, eclipse only knows about packages that are part of the SDK. This does not include all packages that are part of android.

If you look through the AOSP files, you will find methods and variables that are hidden. Some classes are simply not included in the SDK. Other packages are considered to be "internal" and thus you can not access them easily (infact, if a package is internal eclipse has a line that will specifically block all packages from being imported).

Most likely, you have not updated your build path to include an updated framework.jar file. There are quite a few resources available for these tasks. This answer here: How do I build the Android SDK with hidden and internal APIs available? will give you a quick rundown on how to get a framework.jar file simply if you are building aosp.

If you aren't building AOSP, I suggest you check out this guide here on using hidden and internal parts of the API. From a quick glance, it doesn't look like any of those packages are internal, so you should be fine by just importing the framework jar which contains all the classes and hidden methods.

Good luck!

OTHER TIPS

Just a little list of quick fixes:

  • try right click on your android-project -> Android Tools -> Fix Project Properties
  • right click on your android-project -> Android Tools -> Add Support Library...
  • is your SDK up-to-date? You can check this in your SDK Manager
  • last thing: go on Project -> make sure that Build Automatically is checked and then do Clean...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top