2

Because I want to use ActiveAndroid and ActiveAndroid-Validation I need to use Maven (which I never heard of until yesterday). So I installed maven and then tried to install ActiveAndroid.

I wrote a custom serializer in ActiveAndroid using JodaTime and included a JodaTime jar in the ActiveAndroid libs folder. When I build the project using ant it works perfectly well. Using Maven I first downloaded and installed JodaTime in Maven using mvn clean install from within the JodaTime source folder. Seeing the following lines this was successful:

[INFO] --- maven-install-plugin:2.4:install (default-install) @ joda-time ---
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.jar
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/pom.xml to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.pom
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3-javadoc.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3-javadoc.jar
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3-sources.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.603s
[INFO] Finished at: Thu Sep 26 13:00:54 CEST 2013
[INFO] Final Memory: 12M/81M
[INFO] ------------------------------------------------------------------------

I then tried to install ActiveAndroid using the same mvn clean install from within the ActiveAndroid source folder. This however, resulted in the following errors:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.095s
[INFO] Finished at: Thu Sep 26 13:01:08 CEST 2013
[INFO] Final Memory: 13M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project activeandroid: Compilation failure: Compilation failure:
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[3,21] package org.joda.time does not exist
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[22,16] cannot find symbol
[ERROR] symbol  : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[7,24] cannot find symbol
[ERROR] symbol  : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[19,26] cannot find symbol
[ERROR] symbol  : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[27,28] cannot find symbol
[ERROR] symbol  : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] -> [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/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :activeandroid

Does anybody know how I can solve this? All tips are welcome!

==EDIT== The pom.xml of ActiveAndroid can be found here. I did not change anything in it.

kramer65
  • 50,427
  • 120
  • 308
  • 488

2 Answers2

1

If your IDE does not complain, it means your IDE could build the project.

Then I assume your IDE does not rely on maven to build. I would recommand a stronger integration between maven and your IE. You are not supposed to manually add the libs to your classpath (in IDE)

Your POM miss the dependency

<dependency>
  <groupId>joda-time</groupId>
  <artifactId>joda-time</artifactId>
  <version>2.3</version>
</dependency>
Samuel EUSTACHI
  • 3,116
  • 19
  • 24
  • Ah, awesome! That indeed brings me a step further. It now gives me another error though: Error when generating sources. org.apache.maven.plugin.MojoExecutionException: No Android SDK path could be found. [...] [ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources. I've got Eclipse installed with the whole Android setup and everything. Any other ideas how I could solve this? – kramer65 Sep 26 '13 at 11:43
  • I guess you need to create a system variable : ANDROID_HOME – Samuel EUSTACHI Sep 26 '13 at 11:45
  • I tried setting ANDROID_HOME to /Users/kramer65/dev/adt-bundle-mac-x86_64-20130917 but that results in an error saying: Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources (default-generate-sources) on project activeandroid-tests: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources failed: Error reading /Users/kramer/dev/adt-bundle-mac-x86_64-20130917/tools/source.properties -> [Help 1]. Any other ideas? – kramer65 Sep 26 '13 at 13:09
0

As you have the android-maven-plugin in your build, you need to supply path to the SDK. For this maven plugin, this is done by adding it as property (android.sdk.path) in the properties section of the POM.

So you'll have something like this:

<properties>
    <android.sdk.path>your/path/here</android.sdk.path>
</properties>

For quick solution, you can just add this to the POM's properties section. However, local settings like this usually go to settings.xml file in the conf dir inside your maven installation. This will make this property always present no matter what pom you use. Or, if you skip the activeProfiles part, you'll have to invoke maven with that profile enabled - "mvn -pandroidProfile clean install".

<profiles>
    <profile>
        <id>androidProfile</id>
        <properties>
            <android.sdk.path>your/path/here</android.sdk.path>
        </properties>
    </profile>
</profiles>
<activeProfiles>
    <activeProfile>androidProfile</activeProfile>
</activeProfiles>
n1ckolas
  • 4,380
  • 3
  • 37
  • 43
vsigler
  • 1
  • 1
  • 1