Note that there are some explanatory texts on larger screens.

plurals
  1. POStand-alone test project for a library project on Android
    text
    copied!<p>My question is: <strong>How do I create an Android <em>stand-alone</em> test project for an Android library?</strong></p> <p>I've got my Android <em>library</em> (which is marked as "Library" in the project settings) and an Android project containing my JUnit test classes. The <em>test</em> project correctly references the Android library (in the project settings under "Android").</p> <p>My <em>library</em> source code is located in the package <code>com.mayastudios</code>. All my test cases are also located in the same package (but in a different project). So basically I have something like this:</p> <pre><code>+- MyLibraryProject +- src +- com/mayastudios/MyClass.java +- AndroidManifest.xml +- ... +- MyTestProject (references MyLibraryProject) +- test +- com/mayastudios/MyClassTests.java +- AndroidManifest.xml +- ... </code></pre> <p>Here's the Android manifest for the <em>test</em> project:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.spatialite.test" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="10" /&gt; &lt;instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.mayastudios" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; &lt;application android:label="Spatialite-NewApi-UnitTests"&gt; &lt;uses-library android:name="android.test.runner" /&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>However, when I run the <em>test</em> project (from Eclipse with ADT, using "Run As -> Android JUnit Test") I get the following error:</p> <pre><code>Unable to find instrumentation target package: com.mayastudios </code></pre> <p>Here's the complete Console log:</p> <pre><code>[2012-04-24 17:24:20 - spatialite-test] Android Launch! [2012-04-24 17:24:20 - spatialite-test] adb is running normally. [2012-04-24 17:24:20 - spatialite-test] Performing android.test.InstrumentationTestRunner JUnit launch [2012-04-24 17:24:20 - spatialite-test] Automatic Target Mode: using device '3732FBC2711300EC' [2012-04-24 17:24:20 - spatialite-test] Uploading spatialite-test.apk onto device '3732FBC2711300EC' [2012-04-24 17:24:20 - spatialite-test] Installing spatialite-test.apk... [2012-04-24 17:24:22 - spatialite-test] Success! [2012-04-24 17:24:22 - spatialite-test] Launching instrumentation android.test.InstrumentationTestRunner on device 3732FBC2711300EC [2012-04-24 17:24:22 - spatialite-test] Collecting test information [2012-04-24 17:24:23 - spatialite-test] Test run failed: Unable to find instrumentation target package: com.mayastudios </code></pre> <p>I tried to remove the <code>&lt;instrumentation&gt;</code> tag from the manifest which didn't work.</p> <p>The only way I got this working so far was to create a default Android project (with an Activity), reference it from my test project and use the package name of this default Android project as <code>targetPackage</code> under <code>&lt;instrumentation&gt;</code>. But that's not what I want. I want a stand-alone test project.</p> <p>Any suggestions?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload