Unable To Find Instrumentation Target Package: Com.xyz
Solution 1:
You have to create and setup an Application Project that depends on the Library Project, in order to test the Library Project. Quoting from official developer's guide:
Testing a Library Project
There are two recommended ways of setting up testing on code and resources in a library project:
You can set up a test project that instruments an application project that depends on the library project. You can then add tests to the project for library-specific features.
You can set up a set up a standard application project that depends on the library and put the instrumentation in that project. This lets you create a self-contained project that contains both the tests/instrumentations and the code to test.
Android Library Projects are not built directly, but are built along with the Main Application Project. In another words, you cannot compile it directly to its own .apk and run it on an Android device. On the other hand, instrumentation tests work by running the test project application ("Run As..."->"Android JUnit Test" in Eclipse) after installing both app.apk and test.apk on the device, and then using test.apk to manipulate the app.apk—hence the "instrumentation" part of the test name.
Update:
Note that if you use second approach, you can create a Test Project testing Library Project without creating a third Application Project, because a Test Project itself is also a regular Application Project.
Solution 2:
When you create android test project remember to set good target package
<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.example.test" <-------------------android:versionCode="1"android:versionName="1.0" ><uses-sdkandroid:minSdkVersion="8" /><instrumentationandroid:name="android.test.InstrumentationTestRunner"android:targetPackage="com.example.test" > <-----------------
</instrumentation><applicationandroid:icon="@drawable/ic_launcher"android:label="@string/app_name" ><uses-libraryandroid:name="android.test.runner" /><activityandroid:name="TestActivity" /></application></manifest>
Solution 3:
In my case, I was running with gradle, running just the connectedInstrumentTest task with
./gradlew connectedInstrumentTest
and I was getting the "Unable to find instrumentation info" error... The problem was I also needed to include the installDebug task to be executed before the connectedInstrumentTest task, like this:
./gradlew installDebug connectedInstrumentTest
Post a Comment for "Unable To Find Instrumentation Target Package: Com.xyz"