2

因为我想使用ActiveAndroidActiveAndroid-Validation我需要使用 Maven(直到昨天我才听说过)。所以我安装了maven,然后尝试安装ActiveAndroid。

我使用JodaTime在 ActiveAndroid 中编写了一个自定义序列化程序,并在 ActiveAndroid libs 文件夹中包含了一个 JodaTime jar。当我使用它构建项目时,效果非常好。使用 Maven 我首先使用JodaTime 源文件夹中的 Maven下载并安装了 JodaTime。看到以下几行这是成功的:antmvn clean install

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

然后我尝试使用mvn clean installActiveAndroid 源文件夹中的相同内容安装 ActiveAndroid。然而,这导致了以下错误:

[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

有谁知道我该如何解决这个问题?欢迎所有提示!

==EDIT== ActiveAndroid 的 pom.xml 可以在这里找到。我没有改变它。

4

2 回答 2

1

如果您的 IDE 没有报错,这意味着您的 IDE 可以构建项目。

然后我假设你的 IDE 不依赖 maven 来构建。我建议在 Maven 和您的 IE 之间进行更强大的集成。您不应该手动将库添加到您的类路径(在 IDE 中)

你的 POM 错过了依赖

<dependency>
  <groupId>joda-time</groupId>
  <artifactId>joda-time</artifactId>
  <version>2.3</version>
</dependency>
于 2013-09-26T11:32:49.747 回答
0

由于您的构建中有 android-maven-plugin,因此您需要提供 SDK 的路径。对于这个 maven 插件,这是通过将其作为属性 (android.sdk.path) 添加到 POM 的属性部分来完成的。

所以你会有这样的东西:

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

为了快速解决,您可以将其添加到 POM 的属性部分。但是,像这样的本地设置通常会转到 Maven 安装中 conf 目录中的 settings.xml 文件。无论您使用什么 pom,这将使该属性始终存在。或者,如果您跳过 activeProfiles 部分,则必须在启用该配置文件的情况下调用 maven - “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>
于 2013-09-27T08:27:26.580 回答