0

I'm converting a simple android app to Maven, and I've hit a snag with a 3rd party jar (ActiveAndroid) that contains an annotation class that I'm using within my code. I've confirmed that the jar does contain the annotations class files, and the jar works fine when I include it in the libs directory, and compile with Eclipse.

Here's my POM.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.danh32</groupId>
    <artifactId>testapp</artifactId>
    <version>1.0</version>
    <packaging>apk</packaging>
    <name>testapp</name>

    <properties>
        <platform.version> 4.1.1.4</platform.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>actionbarsherlock</artifactId>
            <version>4.2.0</version>
            <type>apklib</type>
        </dependency>

        <dependency>
            <groupId>com.activeandroid</groupId>
            <artifactId>activeandroid</artifactId>
            <version>LATEST</version>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>

            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.5.0</version>
                <configuration>
                    <androidManifestFile>${project.basedir}/AndroidManifest.xml
                    </androidManifestFile>
                    <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                    <resourceDirectory>${project.basedir}/res</resourceDirectory>
                    <nativeLibrariesDirectory>${project.basedir}/src/main/native
                    </nativeLibrariesDirectory>
                    <sdk>
                        <platform>16</platform>
                    </sdk>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

And here's my compilation error:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.339s
[INFO] Finished at: Wed Apr 10 14:18:51 CDT 2013
[INFO] Final Memory: 17M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project testapp: Compilation failure: Compilation failure:
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[9,43] cannot find symbol
[ERROR] symbol  : class ConflictAction
[ERROR] location: @interface com.activeandroid.annotation.Column
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[15,32] cannot find symbol
[ERROR] symbol  : method unique()
[ERROR] location: @interface com.activeandroid.annotation.Column
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[15,47] cannot find symbol
[ERROR] symbol  : method onUniqueConflict()
[ERROR] location: @interface com.activeandroid.annotation.Column
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[15,66] cannot find symbol
[ERROR] symbol  : variable ConflictAction
[ERROR] location: class com.danh32.testapp.db.DSLocation
[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.

I'm just starting out with Maven and compiling Android apps outside of Eclipse, so I'm sure I'm missing something simple. Any nudge in the right direction is highly appreciated!

Thanks!

danh32
  • 6,234
  • 2
  • 38
  • 39
  • Try to compile project with `-X` command line option and see if the jar is actually in classpath. If it is, then it doesn't contain necessary classes. – Andrew Logvinov Apr 10 '13 at 20:53
  • I ran with the -X flag, and it's showing up in the classpath list. As I'm sure the jar contains the right classes, as I can use the deployed jar in Eclipse, and everything compiles and runs correctly. – danh32 Apr 10 '13 at 21:07
  • 1
    You're using `LATEST`. Is it possible you have more than one version of that artifact, and Maven is picking up a different one from Eclipse? – Joe Apr 15 '13 at 12:23
  • @Joe, that was it! There was a cached version in my local repo that was at version 1.1. I assumed deleting the 1.1 version from archiva would be enough. After deleting the local repo and running again, it builds! If you don't mind adding your comment as an answer, I can award you the bounty. – danh32 Apr 16 '13 at 13:11

3 Answers3

1

it doesn't look like the active android artifact is available in the Maven Central Repo (see this search). You can install that jar in your own local repository (using mvn install-file but that will only work on your local machine. Alternatively you can deploy that artifact to a repository that you control and reference that in your POM.

Chris
  • 22,923
  • 4
  • 56
  • 50
  • Thanks! I've already got it deployed on an Archiva instance that I'm running on my server. The ActiveAndroid dependency is definitely being filled, as mvn dependency:tree and mvn dependency:list aren't showing any errors. – danh32 Apr 10 '13 at 21:03
1

You're using LATEST. Is it possible you have more than one version of that artifact, and Maven is picking up a different one from Eclipse?

Joe
  • 29,416
  • 12
  • 68
  • 88
0

Have you considered class version problem? Just speculating, but it could be that the jar was built using 1.6 JDK (target 1.6) Your POM has specified the source and target as 1.5, considering you are also using 1.5 JDK, it is possible that the compiler is simply not able to read the classes in your jar file compiled with 1.6

Kalpak Gadre
  • 6,285
  • 2
  • 24
  • 30
  • Found my answer in the comments above, but this is a good point and something for me to look out for in the future. – danh32 Apr 16 '13 at 17:27
  • @danh32 I generally rely on building from command line. Makes a lot of things simpler by removing the IDE clutter. – Kalpak Gadre Apr 16 '13 at 17:28