With the help of a few other answers I finally managed to import everything. Putting it all together, just copyiing the jar into libs
will not be sufficient. Here's how it works in Andmore (ADT should be similar but some options apparently differ):
- Make sure your SDK is up to date. Specifically, you want the latest version of Extras > Android Support Library (should be version 22 or higher) and a matching version of Tools > Android SDK Build-tools.
- If you have a copy of
android-support-v4.jar
in the libs
folder of your app's source tree, replace it with a recent copy from <sdk>/extras/android/support/v7/appcompat/libs
. (If you have other Android support JARs in that location, you may need to update those as well.)
- Copy
<sdk>/extras/android/support/v7/appcompat
and <sdk>/extras/android/support/design
into your workspace folder. (Not really necessary, but using a local copy will prevent polluting your SDK setup with Eclipse-generated files.
- Select File > New... > Android Project.
- Select Create project from existing source and select your copy of the
appcompat
folder. Be sure to select at least API 22 as a build target (I needed to use API 23, YMMV), and don't forget to give it a meaningful name.
- When import has finished, open the properties of the new project, go to Android and check Is Library.
- Repeat the same two steps to import the design library. After import, in its project properties, go to Android, and in Libraries add a reference to the
appcompat
project.
- Open the properties of your app project, go to Android, and in Libraries add a reference to the
design
project.
I had to make some minor modifications to my source code as some resource identifiers are no longer constants as of API 14, requiring me to convert a switch
statement to a series of if
s. After that, I could finally build my app.
This should work for other Android libraries as well – their locations are documented in http://developer.android.com/tools/support-library/features.html.
Edit: There may be an easier way: Both ADT and Andmore also have Android Tools > Add Support Library, which might make a few of the aforementioned steps easier, which installs the most recent version of the support library. But you still have to add them to your project by hand.