FAQ

[android-developers] Maven: "dx: can't find dx.jar"

Philipp Jenke
Oct 12, 2011 at 8:40 am
Hi group,

I have a problem building my app via Maven. I set up an android
project via Eclipse. It builds correctly and I can deploy it (both on
the emulator and on my device). Additionally, I set up a Maven build
script pom.xml (see below). The first part of the build seems to run
successfully, however, when calling dx it seems to fail. The
ANDROID_HOME variable is set correctly. However, there seem to be some
recent changes in the Android SDK (the tools moved from $ANDROID_HOME/
platforms/android-* to $ANDROID_HOME/platform-tools). The dx is
located under $ANDROID_HOME/platform-tools, the dx.jar under
$ANDROID_HOME/platform-tools/lib/.

Any help appreciated.

Thanks,
Philipp

--------------- MAVEN BUILD ERROR MESSAGE -------------------------

pjenke$ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building AndroidTest3D 0.0.1-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @
AndroidTest3D ---
[INFO] Deleting /Users/pjenke/pjenke/programming/android/android-game-
tutorial-project/target
[INFO]
[INFO] --- maven-android-plugin:2.6.0:generate-sources (default-
generate-sources) @ AndroidTest3D ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Copying local resource files to combined resource directory.
[INFO] /Users/pjenke/android-sdk-mac_x86/platforms/android-8/tools/
aapt [package, -m, -J, /Users/pjenke/pjenke/programming/android/
android-game-tutorial-project/target/generated-sources/r, -M, /Users/
pjenke/pjenke/programming/android/android-game-tutorial-project/
AndroidManifest.xml, -S, /Users/pjenke/pjenke/programming/android/
android-game-tutorial-project/target/generated-sources/combined-
resources/res, -A, /Users/pjenke/pjenke/programming/android/android-
game-tutorial-project/assets, -I, /Users/pjenke/android-sdk-mac_x86/
platforms/android-8/android.jar]
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @
AndroidTest3D ---
[debug] execute contextualize
[WARNING] Using platform encoding (MacRoman actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/pjenke/pjenke/
programming/android/android-game-tutorial-project/src/main/resources
[INFO] skip non existing resourceDirectory /Users/pjenke/pjenke/
programming/android/android-game-tutorial-project/target/generated-
sources/extracted-dependencies/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @
AndroidTest3D ---
[WARNING] File encoding has not been set, using platform encoding
MacRoman, i.e. build is platform dependent!
[INFO] Compiling 13 source files to /Users/pjenke/pjenke/programming/
android/android-game-tutorial-project/target/classes
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ AndroidTest3D
---
[INFO] Building jar: /Users/pjenke/pjenke/programming/android/android-
game-tutorial-project/target/AndroidTest3D-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-android-plugin:2.6.0:unpack (default-unpack) @
AndroidTest3D ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-
testResources) @ AndroidTest3D ---
[debug] execute contextualize
[WARNING] Using platform encoding (MacRoman actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/pjenke/pjenke/
programming/android/android-game-tutorial-project/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-
testCompile) @ AndroidTest3D ---
[WARNING] File encoding has not been set, using platform encoding
MacRoman, i.e. build is platform dependent!
[INFO] Compiling 3 source files to /Users/pjenke/pjenke/programming/
android/android-game-tutorial-project/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.9:test (default-test) @
AndroidTest3D ---
[INFO] Surefire report directory: /Users/pjenke/pjenke/programming/
android/android-game-tutorial-project/target/surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.androidtest3d.test.math.MathHelpersTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.032
sec
Running com.androidtest3d.test.math.MyMatrixTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001
sec
Running com.androidtest3d.test.math.MyVectorTest
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001
sec

Results :

Tests run: 12, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-android-plugin:2.6.0:dex (default-dex) @
AndroidTest3D ---
[INFO] /Users/pjenke/android-sdk-mac_x86/platforms/android-8/tools/dx
[--dex, --output=/Users/pjenke/pjenke/programming/android/android-game-
tutorial-project/target/classes.dex, /Users/pjenke/pjenke/programming/
android/android-game-tutorial-project/target/android-classes]
dx: can't find dx.jar
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 18.656s
[INFO] Finished at: Sun Oct 09 13:10:25 CEST 2011
[INFO] Final Memory: 8M/20M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
com.jayway.maven.plugins.android.generation2:maven-android-plugin:
2.6.0:dex (default-dex) on project AndroidTest3D:
MojoExecutionException: ANDROID-040-001: Could not execute: Command = /
bin/sh -c cd /Users/pjenke/pjenke/programming/android/android-game-
tutorial-project && /Users/pjenke/android-sdk-mac_x86/platforms/
android-8/tools/dx --dex --output=/Users/pjenke/pjenke/programming/
android/android-game-tutorial-project/target/classes.dex /Users/pjenke/
pjenke/programming/android/android-game-tutorial-project/target/
android-classes, Result = 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with
the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


---------------- POM.XML ----------------------------

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
" rel="nofollow">http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.androidtest3d</groupId>
<artifactId>AndroidTest3D</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>AndroidTest3D</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</
groupId>
<artifactId>maven-android-plugin</artifactId>
<version>2.6.0</version>
<configuration>
<sdk>
<platform>8</platform>
</sdk>
<emulator>
<avd>em22</avd>
</emulator>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>
</build>
</project>

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
reply

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›

1 user in discussion

Philipp Jenke: 1 post