Unable to resolve activity for: Intent

后端 未结 7 1805
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 08:21

I am having a problem in running Android unit test. I got this error when I tried to run a simple test.

Here\'s the log:

Blockquote java.la

相关标签:
7条回答
  • 2021-01-17 08:58

    This can also be cause by a missing

    Make sure you have a corresponding entry in your manifest.

    <activity android:name=".SplashActivity"  ...
    
    0 讨论(0)
  • 2021-01-17 09:06

    I had specific similar problem while using the AndroidAnnotations lib.

    Later, I found out it was due to forgetting to use the generated class (MyActivity_ instead of MyActivity).

    0 讨论(0)
  • 2021-01-17 09:12

    Try to check your Manifest.xml file:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.tablet.test"
          android:versionCode="1"
          android:versionName="1.0">
        <application android:icon="@drawable/icon" android:label="@string/app_name">
    
        <uses-library android:name="android.test.runner" />
        </application>
        <uses-sdk android:minSdkVersion="8" />
        <!-- This line below! -->
        <instrumentation android:targetPackage="com.tablet.tablet"
        android:name="android.test.InstrumentationTestRunner" /> 
    </manifest> 
    

    You need to check the following line:

    <instrumentation android:targetPackage="com.tablet.tablet"
    android:name="android.test.InstrumentationTestRunner" /> 
    

    So the targetPackage must be the same as in your code.

    0 讨论(0)
  • 2021-01-17 09:12

    I've had two activities with same name in different packages. Issue was about importing from the wrong package. I spend much time on it maybe it will save someone some time.

    0 讨论(0)
  • 2021-01-17 09:14

    I had a similar problem with a simple test project for an app that was just a splash screen. I found that I had implemented the constructor wrong. My initial implementation of the constructor was this...

    public SplashScreenTest(){
        super("com.mycomp.myapp.SplashScreen", SplashScreen.class);
    }
    

    After some beating my head against the wall, I somehow decided to remove the SplashScreen from the pkg argument of super(). My successful implementation is now like this...

    public SplashScreenTest() {
        super("com.mycomp.myapp", SplashScreen.class);
    }
    

    I hope that this helps you or others solve the problem.

    0 讨论(0)
  • 2021-01-17 09:16

    For the keys being sent twice issue, are you sure you're not now getting both the Down and Up actions? I had this issue when using Robotium, and generated this to make things easier:

    import android.view.KeyCharacterMap;
    import android.view.KeyEvent;
    import android.widget.EditText;
    import com.jayway.android.robotium.solo.Solo;
    
            public static void type(Solo robot, EditText edit, String text) {
                int index = 0;
                //Find the index of this control, as Robotium doesn't seem to like R.id
                for (int i = 0; i < robot.getCurrentEditTexts().size(); i++) {
                    if (robot.getCurrentEditTexts().get(i).getId() == edit.getId()) {
                        index = i;
                    }
                }
    
                robot.clickOnEditText(index);
    
                KeyCharacterMap map = KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD);
                KeyEvent[] events = map.getEvents(text.toCharArray());
    
                for (int event = 0; event < events.length; event++) {
                    if (events[event].getAction() == KeyEvent.ACTION_DOWN) {
                        robot.sendKey(events[event].getKeyCode());
                    }
                }
            }
    
    0 讨论(0)
提交回复
热议问题