Maven 找不到外部 jar 的注释



我正在将一个简单的android应用程序转换为Maven,并且我在第三方jar (ActiveAndroid)中遇到了一个障碍,该jar包含我在代码中使用的注释类。我已经确认jar确实包含注释类文件,并且当我将它包含在libs目录中并使用Eclipse进行编译时,jar可以正常工作。

这是我的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>

这是我的编译错误:

[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.

我刚开始使用Maven并在Eclipse之外编译Android应用程序,所以我肯定我错过了一些简单的东西。任何在正确方向上的推动都是非常感谢的!

谢谢!

您正在使用LATEST。是否有可能您有该工件的多个版本,而Maven从Eclipse中选择了一个不同的版本?

看起来Maven Central Repo中没有活动的android工件(参见此搜索)。您可以在您自己的本地存储库中安装该jar(使用mvn install-file),但这只适用于您的本地机器。或者,您可以将该工件部署到您控制的存储库中,并在您的POM中引用它。

您考虑过类版本问题吗?你的POM已经将源和目标指定为1.5,考虑到你也在使用1.5 JDK,有可能编译器根本无法读取用1.6

编译的jar文件中的类。

相关内容

  • 没有找到相关文章

最新更新