测试 运行 失败:无法找到以下的检测信息:ComponentInfo{com.view.asim.mixuntong.test/android.test.InstrumentationTestRunner}

Test running failed: Unable to find instrumentation info for: ComponentInfo{com.view.asim.mixuntong.test/android.test.InstrumentationTestRunner}

我用的是Android studio verison 2.3.1,我想用espresso来测试,但是遇到了如下图的问题Test running failed

我的测试java文件

package com.view.asim;

import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.view.asim.activity.MainActivity;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
 * Created by OF on 2017/4/28.
 */

@RunWith(AndroidJUnit4.class)
@LargeTest
public class MakeSureLogin {
    private String mStringToBetyped;
    @Rule
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
            MainActivity.class);

    @Before
    public void initValidString() {
        // Specify a valid string.
    }

    @Test
    public void changeText_sameActivity() {

        // Check that the text was changed.
        onView(withId(R.id.account_txt)).perform().check(matches(withText(mStringToBetyped)));

    }
}

我知道在 Whosebug 中也有人问过类似的问题,也有人回答过,但是那些解决方案(比如 this)无法解决我的问题。 有人说可以 specific instrumentation runner ,但是 Android studio version 2 中没有这个动作。3.I 认为这可能与 multildex 有关,真的希望有人能帮助我,任何建议都会非常 appreciated.Here 我的 build.gralde 文件

    defaultConfig {
       //...
       multiDexEnabled true
       testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
       //...
    }
    productFlavors {
           zixuntong{
                applicationIdSuffix ".mixuntong"
                manifestPlaceholders = otherHolderMap
                manifestPlaceholders.put("PACKAGE_NAME",ASIM_PKG_NAME+applicationIdSuffix)
                buildConfigField "boolean", "isAddShare", "false"
                buildConfigField "boolean", "isZXT", "true"
            }
    }
        //.....
        androidTestZixuntongCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
                exclude group: 'com.android.support', module: 'support-annotations'
            })




   //    compile 'com.android.support:support-annotations:22.2.0'
        androidTestZixuntongCompile 'com.android.support.test:runner:0.5'
        testCompile 'junit:junit:4.12'
        androidTestZixuntongCompile('com.android.support:multidex-instrumentation:1.0.1') {
            exclude group: 'com.android.support', module: 'multidex'
        }
        configurations.all {
            resolutionStrategy.force 'com.android.support:support-annotations:23.1.0'
        }
    //...
//had trying follow script,but still doesn't work
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',

{ exclude group: 'com.android.support', module: 'support-annotations' })

我发现我在将 Android Studio 从 2.3.1 升级到 2.3.2 后解决了这个问题。