Android: Unit Test Issues

I’ve created this project for testing my Android Application and tried to start it.
After starting I have received next error:

Test run failed: Unable to find instrumentation info for:
ComponentInfo {<my package>/android.test.InstrumentationTestRunner}

After few hours of investigation I have found solution for this situation.

Problem
So, Problem is name of package in the manifest files.  The package in “real” manifest file and test manifest file are equal. For instance, look at the package com.blogspot.jugn in both manifests

Test manifest:

<?xml version=“1.0” encoding=“utf-8″?>
<manifest  xmlns:android=“http://schemas.android.com/apk/res/android&#8221;
package=“com.blogspot.jugn”  android:versionCode=“1” android:versionName=“1.0”>
<uses-sdk android:minSdkVersion=“7”/>
<instrumentation android:targetPackage=“com.blogspot.jugn”  android:name=“android.test.InstrumentationTestRunner” />
<application android:icon=“@drawable/icon” android:label=“@string/app_name”>
<uses-library android:name=“android.test.runner” />
</application>
<!–  Add permissions for send sms messages–>
<uses-permission android:name=“android.permission.SEND_SMS” />
<uses-permission android:name=“android.permission.WRITE_SMS”/>
</manifest>

Project manifest:

<?xml version=“1.0” encoding=“utf-8″?>
<manifest xmlns:android=“http://schemas.android.com/apk/res/android&#8221;
package=“com.blogspot.jugn” android:versionCode=“1” android:versionName=“1.0”>
<application android:label=“@string/app_name” android:icon=“@drawable/visa” android:debuggable=“true”>
<activity android:name=“.AccountList” android:label=“@string/app_name”>
<intent-filter>
<action android:name=“android.intent.action.MAIN” />
<category android:name=“android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion=“7” android:targetSdkVersion=“7” />
<!– Allows an application to read SMS messages. –>
<uses-permission android:name=“android.permission.READ_SMS”/>
</manifest>

Solution
Change package in test project to something else, I have used next convention: put test instead of first part of package like this :

test.blogspot.jugn 

And result manifest file should be like this

<manifest xmlns:android=“http://schemas.android.com/apk/res/android&#8221;
package=“test.blogspot.jugn “ android:versionCode=“1” android:versionName=“1.0”>
<uses-sdk android:minSdkVersion=“7”/>
<instrumentation android:targetPackage=“test.blogspot.jugn “ android:name=“android.test.InstrumentationTestRunner” />
<application android:icon=“@drawable/icon” android:label=“@string/app_name”>
<uses-library android:name=“android.test.runner”/>
</application>
<!– Add permissions for send sms messages–>
<uses-permission android:name=“android.permission.SEND_SMS”/>
<uses-permission android:name=“android.permission.WRITE_SMS” />
</manifest>

That is all manipulation for fixing this problem.

Cheers!

READ  Java Unsupported Major Minor version 51 ERROR

Leave a Reply

Your email address will not be published. Required fields are marked *