views:

296

answers:

1

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]                ^
+1  A: 

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

Christopher
Thanks Christopher! That created the necessary build files and it seems like it's the right solution, but it's not quite working yet. Here's the current problem: http://stackoverflow.com/questions/2472059/class-ref-in-pre-verified-class-resolved-to-unexpected-implementation-when-runn
Mike