由于 Android Java 项目使用 Ant 作为构建工具,因此使用 Ivy 进行依赖管理对我来说似乎是一个自然的选择。然而,虽然基本设置工作正常,但我遇到了一个奇怪的问题。我在 GitHub 上创建了一个现有示例的分支,以轻松重现该问题。
关键是,依赖项可以很好地下载到“libs”目录中,但是调用的构建过程ant debug
似乎没有找到 JAR。但是,如果我将“resolve”目标称为不是我重载的“-pre-build”目标的一部分,而是像在ant resolve debug
.
我已经验证了这些库在“-pre-build”完成之前确实在“libs”中(通过将“libs”中的文件列为“-pre-build”目标的一部分),所以我真的想知道为什么他们找不到。
要重现,重要的是在运行 ant 之前从“libs”中删除库。任何想法这里出了什么问题?
resolve:
[ivy:retrieve] :: Apache Ivy 2.3.0-rc1 - 20120416000235 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] :: loading settings :: file = /Users/seschube/development/IvyAndroidExample/ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: com.example#ivy-android-example;0.1
[ivy:retrieve] confs: [default]
[ivy:retrieve] found org.acra#acra;4.2.3 in acra
[ivy:retrieve] found com.google.inject#guice;2.0-no_aop in maven2
[ivy:retrieve] found com.google.zxing.core#core;1.6 in zxing
[ivy:retrieve] :: resolution report :: resolve 115ms :: artifacts dl 5ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 3 | 0 | 0 | 0 || 4 | 0 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: com.example#ivy-android-example
[ivy:retrieve] confs: [default]
[ivy:retrieve] 4 artifacts copied, 0 already retrieved (1195kB/76ms)
-pre-build:
[echo] The "libs" directory contains: acra-4.2.3.jar;core-1.6.jar;guice-2.0-no_aop-javadoc.jar;guice-2.0-no_aop.jar
-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[renderscript] No RenderScript files to compile.
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
-compile:
[javac] Compiling 3 source files to /Users/seschube/development/IvyAndroidExample/bin/classes
[javac] /Users/seschube/development/IvyAndroidExample/src/com/example/IvyAndroidExampleActivity.java:7: error: package org.acra does not exist
[javac] import org.acra.*;
[javac] ^
[javac] /Users/seschube/development/IvyAndroidExample/src/com/example/IvyAndroidExampleActivity.java:8: error: package com.google.inject does not exist
[javac] import com.google.inject.*;
[javac] ^
[javac] /Users/seschube/development/IvyAndroidExample/src/com/example/IvyAndroidExampleActivity.java:9: error: package com.google.zxing does not exist
[javac] import com.google.zxing.*;
[javac] ^
[javac] 3 errors
BUILD FAILED