Classy Data

Import Android Libraries into Eclipse

Android Aars and Eclipse Compatibility

One of the major drawbacks of Android development with Eclipse is lack of support for importing Android aars (library archives with both classes and resources) into Eclipse. The solution is to create an Eclipse library project for each aar and import the contents of the aar to suit the project format. An automated process to set up Eclipse library projects is available as the gradle-eclipse-aar-plugin. As the name indicates, it uses Gradle to build the library projects.

The strategy here is to set up the all the Eclipse library projects that will be needed in a self-contained project called Classyfy. Next, import these projects into Eclipse so they are available to resolve library dependencies of Classy Apps or any other Android Maven project imported into Eclipse.

Classyfy

Clone the Classyfy Github repository to your PC. In a command window, go to your chosen workspace location and run:

git clone https://github.com/cybersearch2/classyfy.git

Upon completion, the project will be found in the "classyfy" sub directory. Change to this directory and you will find a Gradle project with a single gradle.build file as well as a Maven pom.xml. Maven is configured to run the Gradle Wrapper with the "generateEclipseDependencies" argument. Proceed as follows:

mvn exec:java
mvn install

The second line executes a custom Maven plugin to remove duplicate library filename "internalImpl.jar" which comes from several support-v4 aars. Eclipse complains about this duplication when the library projects are imported.

Upon completion there should be 15 Eclipse library projects under the "aarDependencies" sub directory. You are now ready to install Classy Apps.

The Classyfy project also builds an application that can be installed on a device by running gradlew installDebug. This is the same demonstration application that is in Classy Apps and can be used as a template for working with Gradle and Eclipse.

Classy Apps is configured with library settings that are linked to the Classyfy "aarDependencies" directory by relative paths eg.

../../../classyfy/aarDependencies/com.android.support-support-v4-24.2.1

The libraries are configured in the project.properties file of the root project directory.

How to import library projects

If you need to import the aarDependencies library projects into your Eclipse workspace, follow these steps:

  1. File -> Import -> General -> Existing Projects into Workspace and an "Import Projects" dialog will pop up.
  2. Tick "Search for nested projects" and browse to the aarDependencies location.
  3. Select all library projects. Just click Finish to complete the import.

The library projects should load without error.

If you need to adjust library locations, right-click on the project in the Eclipse explorer window, select properties->Android and change settings in in the "Library" section with "Add" and "Remove" buttons.