Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid -- Unable to resolve activity in JUnit test only for some activities
    text
    copied!<p>When I run a JUnit test for one of my activities I get the above error, but not for another activity. Both activities are in the same package. </p> <p>Here's my barebones code for activity that doesn't work. (the one that does work is the same, just switch the activity name).</p> <pre><code>public class CounterTest extends ActivityInstrumentationTestCase2&lt;Reward&gt;{ Activity mActivity; public CounterTest() { super("com.morningsun.caffeinecounter", Reward.class); } @Override protected void setUp(){ try{ super.setUp(); mActivity = this.getActivity(); }catch(Exception e){ e.printStackTrace(); } } public void test(){ Assert.assertTrue(1==1); } </code></pre> <p>And here's my manifest instrumentation info</p> <p>`</p> <pre><code> &lt;&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.missaion.caffeinecounter.test" android:versionCode="1" android:versionName="1.0"&gt; &lt;uses-sdk android:minSdkVersion="7" /&gt; &lt;instrumentation android:targetPackage="com.morningsun.caffeinecounter" android:name="android.test.InstrumentationTestRunner" /&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt; &lt;uses-library android:name="android.test.runner" /&gt; &lt;/application&gt; &lt;/manifest&gt; &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.morningsun.caffeinecounter" android:versionCode="2" android:versionName="1.05"&gt; &lt;uses-sdk android:minSdkVersion="7" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.VIBRATE" /&gt; &lt;application android:icon="@drawable/icon" android:label="@string/Title"&gt; &lt;activity android:name=".CaffeineCounterActivity" android:label="@string/Title" android:launchMode="singleTask"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".DrinkSelector" android:theme="@android:style/Theme.Dialog" android:noHistory="true" android:label="@string/Select" /&gt; &lt;activity android:name=".Plot" android:noHistory="true" android:label="@string/PlotData" /&gt; &lt;activity android:name=".Info" android:noHistory="true" android:label="@string/InfoText" /&gt; &lt;activity android:name=".SendDialog" android:theme="@android:style/Theme.Dialog" android:noHistory="true" android:label="@string/SaveFile" /&gt; &lt;activity android:name=".DrinkDialog" android:theme="@android:style/Theme.Dialog" android:noHistory="true" android:label="@string/AddDrink" /&gt; &lt;activity android:name=".DrinkDialogNonLinear" android:theme="@android:style/Theme.Dialog" android:noHistory="true" android:label="@string/AddDrink" /&gt; &lt;activity android:name=".EditType" android:theme="@android:style/Theme.Dialog" android:noHistory="true" android:label="@string/EditType" /&gt; &lt;activity android:name=".EditTypeStarbucks" android:theme="@android:style/Theme.Dialog" android:noHistory="true" android:label="@string/Select" /&gt; &lt;activity android:name=".DrinkUpdater" android:theme="@android:style/Theme.Dialog" android:noHistory="true" android:label="@string/EditDrink" /&gt; &lt;activity android:name=".AmountDialog" android:theme="@android:style/Theme.Dialog" android:noHistory="true" /&gt; &lt;activity android:name=".NewTypeDialog" android:theme="@android:style/Theme.Dialog" android:noHistory="true" android:label="@string/AddType" /&gt; &lt;activity android:name=".DayList" android:label="@string/DateList"/&gt; &lt;activity android:name=".TypeList" android:theme="@android:style/Theme.Dialog" android:label="@string/Types"/&gt; &lt;activity android:name=".DayDrinkList" android:label="@string/DateDrinkList"&gt; &lt;/activity&gt; &lt;activity android:name=".SodaList" android:theme="@android:style/Theme.Dialog" android:noHistory="true" android:label="@string/SelectDrink" /&gt; &lt;activity android:name=".LimitDialog" android:theme="@android:style/Theme.Dialog" android:noHistory="true" /&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>The other posts on this topic say to check the instrumentation targetPackage and to check the values in the constructor super, which seem okay to me. Any help would be appreciated. </p> <p>Here are the error messages:</p> <pre><code>03-30 13:35:08.853: W/System.err(1727): java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.morningsun.caffeinecounter/.Reward } 03-30 13:35:08.853: W/System.err(1727): at android.app.Instrumentation.startActivitySync(Instrumentation.java:371) 03-30 13:35:08.863: W/System.err(1727): at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:119) 03-30 13:35:08.863: W/System.err(1727): at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:97) 03-30 13:35:08.863: W/System.err(1727): at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:98) 03-30 13:35:08.863: W/System.err(1727): at com.missaion.caffeinecounter.test.CounterTest.setUp(CounterTest.java:33) 03-30 13:35:08.863: W/System.err(1727): at junit.framework.TestCase.runBare(TestCase.java:125) 03-30 13:35:08.863: W/System.err(1727): at junit.framework.TestResult$1.protect(TestResult.java:106) 03-30 13:35:08.863: W/System.err(1727): at junit.framework.TestResult.runProtected(TestResult.java:124) 03-30 13:35:08.863: W/System.err(1727): at junit.framework.TestResult.run(TestResult.java:109) 03-30 13:35:08.863: W/System.err(1727): at junit.framework.TestCase.run(TestCase.java:118) 03-30 13:35:08.863: W/System.err(1727): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 03-30 13:35:08.863: W/System.err(1727): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 03-30 13:35:08.863: W/System.err(1727): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520) 03-30 13:35:08.863: W/System.err(1727): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) </code></pre>
 

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