浓咖啡-膨胀类android.support.v7.widget.ActionBarContainer时出错

时间:2018-12-04 13:16:17

标签: java android android-espresso

我试图在espresso中运行测试以启用RecyclerView的单击,但是当我运行它时,它在下面抛出错误:

  android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class android.support.v7.widget.ActionBarContainer
    Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class android.support.v7.widget.ActionBarContainer
    Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
    at android.view.LayoutInflater.createView(LayoutInflater.java:647)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    at android.support.v7.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:607)
    at android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:518)
    at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:466)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
    at view.MainActivity.onCreate(MainActivity.java:25)
    at android.app.Activity.performCreate(Activity.java:7136)
    at android.app.Activity.performCreate(Activity.java:7127)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
    at android.support.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:667)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: java.lang.NoSuchMethodError: No static method setBackground(Landroid/view/View;Landroid/graphics/drawable/Drawable;)V in class Landroid/support/v4/view/ViewCompat; or its super classes (declaration of 'android.support.v4.view.ViewCompat' appears in /data/app/com.levelapp.converge.convergelevelapp.test-LzAA3yY-jAiBpg-QtnJjCQ==/base.apk)
    at android.support.v7.widget.ActionBarContainer.<init>(ActionBarContainer.java:62)
    ... 31 more



    Test running failed: Instrumentation run failed due to 'Process crashed.'

我看到代码中的所有内容都正确,但是我不知道为什么测试失败。

下面是我的代码:

@RunWith(AndroidJUnit4.class)
public class MainActivityTest {

    @Rule
    public ActivityTestRule<MainActivity> activity = new ActivityTestRule<>(MainActivity.class);

    @Test
    public void loadRecyclerview(){

        onView(ViewMatchers.withId(R.id.rv)).
                perform(RecyclerViewActions.actionOnItemAtPosition(2, ViewActions.click()));
    }

}

此问题是在应用程序的工具栏还是?

0 个答案:

没有答案