FrVaBe
FrVaBe

Reputation: 49341

Include maven dependencies in eclipse "Run As -> Android Application" build

I develop an Android App using eclipse, the Android Development Tools (ADT) plugin and the maven-android-plugin.

Building and installing the application on the commandline (mvn install / adb install) works fine - especially it includes all dependencies specified in the pom.xml.

Deploying the application to Android via eclipse (Run as -> Android Application) does not automatically put the dependencies in the apk file - although specified in the pom.xml. I haven to explicit declare them in the eclipse project Build Path -> Libraries dialog.

Is there a way to make eclipse include the dependencies defined in the pom.xml without definig them twice in the project Build-Path -> Libraries?

EDIT: To clarify - the eclipse project includes a "Maven Dependencies" entry with all dependencies specified in the pom.xml. But these dependencies will not be included in the apk during install via "Run As -> Android Application". To include them, each one has to be extra added in the "Java Build Path -> Libraries" dialog. That's the pain!

Upvotes: 13

Views: 9955

Answers (2)

Raghuram
Raghuram

Reputation: 52635

Perhaps you should look at m2e-android, assuming you are already using M2Eclipse.

Upvotes: 3

rebouny
rebouny

Reputation: 71

I enabled the "Maven Dependencies"-checkmark at "Order and Export" within projects "Java Build Path" configuration and that seems to include all maven dependencies.

These dependencies (compile scope) are put into target/android-classes (and there are a lot of them, most commonly snapshots of internal projects, about 10). I had some other difficulties but that probably is related to the m2eclipse android integration plugin (at least on windows 7).

To get my properly set up maven project running I had to:

either import as maven project or...

clean previously created eclipse files (mvn eclipse:clean, mvn eclipse:eclipse), then enable maven dependecy resolution for that project, adept Java Build Path (gen -> target/android-classes, src -> target/classes, default output folder -> android-classes) and export Maven Dependencies (enable checkmark).

One thing i stumbled upon was this "Could not find *.apk!" error when running or debugging the android application. I could fix that by using a 32bit jdk for the used execution environment.

Upvotes: 4

Related Questions