Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Android libraries with resources without using Eclipse

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?

like image 442
user2683038 Avatar asked Aug 30 '13 05:08

user2683038


People also ask

Can you use Java libraries in Android?

To use a Java library (JAR file) inside your Android project, you can simple copy the JAR file into the folder called libs in your application. *. jar files in this folder are included into the compile classpath via the default build.

Does Android library have application class?

The Application class in Android is the base class within an Android app that contains all other components such as activities and services. The Application class, or any subclass of the Application class, is instantiated before any other class when the process for your application/package is created.

What are libraries in Android Studio?

Android App Development for Beginners The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level.


1 Answers

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:

  • http://developer.android.com/tools/projects/projects-cmdline.html
  • Adding android library project to an android project prevents Ant from building
like image 152
user2683038 Avatar answered Sep 30 '22 03:09

user2683038