4

I'm trying to include a directory-chooser feature in my Android app, but apparently I can't import the library I found. This is the library that I want to use: https://github.com/passy/Android-DirectoryChooser.

I followed this steps:

  • downloaded the zip file and imported it into Eclipse (Import -> Existing Android Code Into Workspace -> selected only library project). The tree now looks like this:

    enter image description here

  • right-clicked on main project and checked Is Library
  • right-clicked on java folder in the main project and selected Use as Source folder
  • right-clicked on my project and added the main library in the Android tab; also added the library in the Java Build Path tab, that now looks like this:

    enter image description here

I don't know what I'm missing, but the line

import net.rdrei.android.dirchooser.DirectoryChooserActivity;

gives me an error saying that The import net cannot be resolved. How can I correctly import this library?

Edward
  • 355
  • 1
  • 5
  • 16

2 Answers2

0

You have imported the library 'main' as a java library, instead import it as an Android Library. Follow steps mentioned in this link : adding-android-library-project-to-eclipse-build-path

Community
  • 1
  • 1
Kakarot
  • 4,252
  • 2
  • 16
  • 18
0

Despite the fact that the README said:

... Import the project into your favorite IDE and add android.library.reference.1=/path/to/Android-DirectoryChooser/library to your project.properties ...

In fact Android-DirectoryChooser support only gradle-based projects as result only Android Annotations

How to fix it

To be able use it in you eclipse project you should:

  1. Change library directory layout
  2. Download third-party jar dependencies
  3. Setup Auto Parcel annotation processing
  4. Add library to your project

Change library directory layout

Directory layout should be plain, like below

directory-chooser
├── AndroidManifest.xml
├── assets
├── libs
├── src
├── res
└── project.properties

Download third-party jar dependencies

After resloving all dependencies libs and compile-libs looks

...
├── compile-libs
│   ├── auto-parcel-processor-0.3.1.jar
│   └── guava-19.0-rc1.jar
├── libs
│   ├── auto-common-0.4.jar
│   ├── auto-parcel-0.3.1.jar
│   ├── auto-value-1.1.jar
│   └── option-1.3.jar
...

Setup annotation processing

For annotation processing you can just use approach from androidannotations. Copy custom_rules.xml for building with ant or fix Factory Path for building from eclipse

Add library to your project

Update your project.properties file, add android.library.reference.1=/path/to/Android-DirectoryChooser/library

CAMOBAP
  • 5,523
  • 8
  • 58
  • 93