Mr. Robot
Mr. Robot

Reputation: 65

Using a Maven Android Library from GitHub in Eclipse

We are making an Android application and we want to use a library called EasyNFC (https://github.com/Mobisocial/EasyNFC).

We're having a load of trouble, however, getting everything to play nicely together. We would like to have EasyNFC available in Eclipse so that we can reference the library from our Android project, but while also maintaining the ability to pull updates (i.e. we don't want to keep copy/pasting). Issues:

  1. EasyNFC is a Maven project (We are already using m2eclipse)
  2. EasyNFC is hosted on Git (We are already using the m2e Git connector)
  3. EasyNFC is meant to be used as an Android library but is NOT an Eclipse project

Is there an easy way to import EasyNFC as a Maven/Git/Android project into Eclipse?

Upvotes: 1

Views: 824

Answers (1)

yorkw
yorkw

Reputation: 41126

EasyNFC is meant to be used as an Android library but is NOT an Eclipse project.

I checked out its pom.xml and have a play with it.

  1. It uses android-2.3.3.jar as dependency in POM doesn't mean it has to be a Android library project.
  2. According to the project structure and <packaging> defined POM, obviously, the producer wants consumer developer use this as a regular java project (bulid as a jar library). In addition, maven-android-plugin defined in POM is verbose, no android phase/goal involved at build time. Also it uses an ancient version 2.8.4 so I guess it is originally created as Android library project and get converted to regular java project recently and didn't clean up the unused code.

Is there an easy way to import EasyNFC as a Maven/Git/Android project into Eclipse?

Suppose you use latest Android SDK & ADT version, in Eclipse (requires m2eclipse), simply import it as a regular mavenized java project: File -> Import ... -> Maven -> Existing Maven Projects, once done, you can see easynfc in Package Explorer has icon marked with capital M and J, which means a Mavenized Java project.

In Android project, add easynfc project into project build path: Properties -> Java Build Path -> Projects -> Add ... then export easynfc project: to build class path: Properties -> Java Build Path -> Order and Export.

Now you should able to use easynfc in your Android project and build/run/debug it in Eclipse.

Hope this helps.

Upvotes: 1

Related Questions