如何建立与使用上的蚂蚁另一个应用程序依赖一个Android测试应用程序? [英] How to build an android test app with a dependency on another app using ant?

查看:119
本文介绍了如何建立与使用上的蚂蚁另一个应用程序依赖一个Android测试应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为MyApp的模块和其他模块调用MyAppTests这对MyApp的依赖。两种模块产生的APK,一只叫MyApp.apk和其他MyAppTests.apk。

我通常的IntelliJ和Eclipse构建这些,但我想创建一个Ant构建为他们的持续集成的目的。

我用Android的更新,以创建一个构建文件为MyApp的,并感谢<一href="http://stackoverflow.com/questions/2465285/how-to-build-an-android-app-with-external-libraries-using-ant/">commonsware's回答我的previous问题,我已经能够使用Ant来构建它成功。

我现在想使用Ant来构建MyAppTests.apk。我构建的构建文件为使用Android的更新前,但是当我运行它,我得到一个错误,指出它没有发现任何一个类中的MyApp。

以一阙从我的previous的问题,我试图把MyApp.apk到我MyAppTests /库,但不幸的是这并不能奇迹般地解决问题。

什么是用蚂蚁时,这取决于类另一个APK建立一个测试应用程序APK的最佳方法是什么?

  $蚂蚁调试
构建文件:build.xml文件
    [设置]项目目标:谷歌的API
    [设置]厂商:谷歌公司
    [设置]平台版本:1.5
    [设置] API级别:3
    【设置】警告:没有的minSdkVersion设置值。应用程序将安装在所有的Andr​​oid版本。

迪尔斯:
     [回应]如果需要创建输出目录...

资源-SRC:
     [回应]生成R.java / Manifest.java从资源...

AIDL:
     [回应]编译AIDL文件转换成Java类...

编译:
    [javac的] 5编译源文件/用户/麦克风/项目/ MyApp的/安卓/ MyAppTests /斌/班
    [javac的] /Users/mike/Projects/myapp/android/MyAppTests/src/com/myapp/test/GsonTest.java:3:找不到符号
    [javac的]符号:类MyApplication的
    [javac的]地址:包com.myapp
    [javac的]进口com.myapp.MyApplication;
    [javac的] ^
 

解决方案

/用户/麦克风/项目/ MyApp的/安卓/ ,假设主要的应用程序源在一个名为的子目录的MyApp ,运行:
安卓创建测试项目-p MyAppTests -m -n ../MyApp MyAppTests

这将产生一个测试文件夹结构和相应的Ant构建文件,这样你就可以这样做:
CD MyAppTests
蚂蚁运行测试

I have a module called MyApp, and another module called MyAppTests which has a dependency on MyApp. Both modules produce APKs, one named MyApp.apk and the other MyAppTests.apk.

I normally build these in IntelliJ or Eclipse, but I'd like to create an ant buildfile for them for the purpose of continuous integration.

I used "android update" to create a buildfile for MyApp, and thanks to commonsware's answer to my previous question I've been able to build it successfully using ant.

I'd now like to build MyAppTests.apk using ant. I constructed the buildfile as before using "android update", but when I run it I get an error indicating that it's not finding any of the classes in MyApp.

Taking a que from my previous question, I tried putting MyApp.apk into my MyAppTests/libs, but unfortunately that didn't miraculously solve the problem.

What's the best way to build a test app APK using ant when it depends on classes in another APK?

$ ant debug
Buildfile: build.xml
    [setup] Project Target: Google APIs
    [setup] Vendor: Google Inc.
    [setup] Platform Version: 1.5
    [setup] API level: 3
    [setup] WARNING: No minSdkVersion value set. Application will install on all Android versions.

dirs:
     [echo] Creating output directories if needed...

resource-src:
     [echo] Generating R.java / Manifest.java from the resources...

aidl:
     [echo] Compiling aidl files into Java classes...

compile:
    [javac] Compiling 5 source files to /Users/mike/Projects/myapp/android/MyAppTests/bin/classes
    [javac] /Users/mike/Projects/myapp/android/MyAppTests/src/com/myapp/test/GsonTest.java:3: cannot find symbol
    [javac] symbol  : class MyApplication
    [javac] location: package com.myapp
    [javac] import com.myapp.MyApplication;
    [javac]                ^

解决方案

In /Users/mike/Projects/myapp/android/, assuming that the main app source is in a subdirectory called MyApp, run:
android create test-project -p MyAppTests -m ../MyApp -n MyAppTests

That will generate a test folder structure and appropriate Ant build files, so you can then do:
cd MyAppTests
ant run-tests

这篇关于如何建立与使用上的蚂蚁另一个应用程序依赖一个Android测试应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆