12

I would like to setup the Android v7 appcompat library in order to use the ActionBar. At

http://developer.android.com/tools/support-library/setup.html#

there is a tutorial how to add libraries with resources using Eclipse. Since I am not using Eclipse I would like to add the library and the accompanying resources by manually editing and copying the required files. Can anyone perhaps provide me with this necessary steps?

user2683038
  • 667
  • 6
  • 17

1 Answers1

13

OK, finally I found it out. The keywords are library project and command line.

In order to add the appcompat v7 as library project to an own project using the command line the following steps worked for me:

  1. Create a copy of the folder android-sdk/extras/android/support/v7/appcompat into the own project space. You may call it anything, we will keep the appcompat name.

    cd my_project

    cp -r android-sdk/extras/android/support/v7/appcompat appcompat

  2. Generate a build.xml file for the library project: execute

    android update lib-project --path appcompat

  3. reference the library project and create the dependency in the project's project.properties file

    android.library.reference.1=appcompat

  4. build the main project:

    ant clean debug

    This will automatically build the support library, too. You generally need a clean build after adding a library or changing the target versions, so the build picks up all the changes.

These are useful resources:

Community
  • 1
  • 1
user2683038
  • 667
  • 6
  • 17
  • Thank you so much for this. I had to use `android update lib-project --target 3 --path . ` in the second step and `android.library.reference.1=/appcompat ` in the third step for it to work – linuxjava Sep 15 '14 at 09:53
  • Yes, the `--target` parameter is usually necessary. Also, I could only build if the target id was set to the latest version (supported by the installed SDK) in both the main project and the support library. No idea if there is another way. – sleske Jan 14 '15 at 21:17