我已经审阅了许多与此相关的问题,但似乎无法找到一个明确的解决方案。我试图使用emma为应用程序提供代码覆盖率,并将robotium用作测试单元。external dropbox.jar位于eclipse的构建路径中。
应用程序和测试用例在eclipse中成功运行,但是在运行脚本时,ant无法找到dropbox.jar依赖项。下面是我的脚本,后面是ant调用日志的一部分
# !/bin/bash
# Code Coverage Script:
# (android:command not found error)
export ANDROID_HOME=/Users/Deverick/android-skds
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
export PATH=$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:/Users/Deverick/Documents/workspace/Diary-Test/libs/dropbox-android-sdk-1.6.1:$PATH
echo $PATH
cd ~/Documents/workspace/
cd Diary
ant clean
cd ..
cd Diary-Test
ant clean
cd ..
android update project --path ./ --name Diary --target android-16 --subprojects
cd Diary-Test
android update test-project --main ../Diary --path ./
ant emma debug install
ant emma debug install test
日志输出:
-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...
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
-compile:
[javac] Compiling 4 source files to /Users/Deverick/Documents/workspace/Diary/bin/classes
[javac] /Users/Deverick/Documents/workspace/Diary/src/jpf/android/diary/Diary.java:2: warning: unmappable character for encoding UTF-8
[javac] // Copyright ? 2012 Josep Portella Florit <hola@josep-portella.com>
[javac] ^
[javac] /Users/Deverick/Documents/workspace/Diary/src/jpf/android/diary/Diary.java:39: package com.dropbox.client2 does not exist
[javac] import com.dropbox.client2.DropboxAPI;
[javac] ^
[javac] /Users/Deverick/Documents/workspace/Diary/src/jpf/android/diary/Diary.java:40: package com.dropbox.client2.android does not exist
[javac] import com.dropbox.client2.android.AndroidAuthSession;
我该如何将这个.jar路径添加到脚本中,以便将其视为一个依赖项?我见过一些关于$classpath的引用。大多数与此相关的问题都使用build.xml文件来添加依赖项,但是每次脚本都会清除build.xml。如有任何澄清,我们将不胜感激!
2条答案
按热度按时间bogh5gae1#
这是一个摘录自
ant
手册页。希望这有帮助。cpjpxq1n2#
所以为了向社区汇报,我找到了解决我的问题的方法,也许是一些开发人员使用的方法
ant
编译android applications with external .jars
.确保jar文件立即位于libs文件夹中,而不是libs的某个子文件夹中。似乎ant不会递归地搜索libs的子文件夹来查找
.jar
文件夹。再次运行脚本时,将包含库依赖项,并从脚本中删除错误。希望有帮助!