I get errors when I try to run insturmentation tests on Android. I wrote an Activity called AudioPlayerActivity , which is in the package com.mycompany.mobile.android.gui, and now I'm trying to check the GUI of this project, and I am running the following error:
java.lang.RuntimeException: Unable to enable action for: Intent {act = android.intent.action.MAIN flg = 0x10000000 cmp = com.mycompany.mobile.android.gui / .AudioPlayerActivity}
I read this question and followed the advice there, but to no avail. I also searched for the error, but did not find any help.
Here's what my AndroidManifest.xml looks like for a test project:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mycompany.mobile.android.gui" android:versionCode="1" android:versionName="1.0" > <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.mycompany.mobile.android.gui" /> <application> <uses-library android:name="android.test.runner" /> </application> <uses-sdk android:targetSdkVersion="7" /> <supports-screens android:anyDensity="true" /> <uses-permission android:name="android.permission.INTERNET"></uses-permission> </manifest>
And here is my Instrumentation test.
package com.mycompany.mobile.android.gui;
import android.test.ActivityInstrumentationTestCase2; import com.mycompany.mobile.android.gui.AudioPlayerActivity; public class TestMusicPlayerActivityTest extends ActivityInstrumentationTestCase2<AudioPlayerActivity> { public TestMusicPlayerActivityTest() { super("com.mycompany.mobile.android.gui", AudioPlayerActivity.class); } public TestMusicPlayerActivityTest(String name) { super("com.mycompany.mobile.android.gui", AudioPlayerActivity.class); } public TestMusicPlayerActivityTest(String pkg, Class<AudioPlayerActivity> activityClass) { super("com.mycompany.mobile.android.gui", AudioPlayerActivity.class); } public void testSomething() { System.out.println("Nothing works :("); System.out.println(getActivity()); } }
We run the whole process through maven, but this should not be part of the problem.
Proven activity, as you can see, also lies in one package. I do not call super-constructor activity instead of a package name, as most people having this problem do.
For your interest, this is AndroidManifest.xml describing the activity being tested:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mycompany.mobile.android.gui" android:versionCode="1" android:versionName="1.0" > <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:debuggable="true" android:theme="@style/NoTitleBar" > <activity android:name="com.mycompany.mobile.android.gui.AudioPlayerActivity" android:screenOrientation="portrait" ></activity> </application> </manifest>
I also added activity to AndroidManifest.xml, but that didn't change anything. I also tried adding the MAIN / LAUNCHER intent filter for the desired activity, but this did not change the test result. I tried to start working with additional functions and without them, which also did not change the result.