java.lang.NoSuchMethodError: No interface method onTransitionToIdle()V

无人久伴 提交于 2019-12-13 15:00:18

问题


PLease i am new to Android Testing, i have being trying to fix an initial NavigationView Test bu i am getting the error. I was just trying to open the drawer and click a menu to go to a new activity.

java.lang.NoSuchMethodError: No interface method onTransitionToIdle()V in class Landroid/support/test/espresso/IdlingResource$ResourceCallback; or its super classes (declaration of 'android.support.test.espresso.IdlingResource$ResourceCallback' appears in /data/app/com.bellman.inecparrot.mock-2/base.apk)
    at android.support.test.espresso.contrib.DrawerActions$IdlingDrawerListener.onDrawerStateChanged(DrawerActions.java:266)
    at android.support.v4.widget.DrawerLayout.updateDrawerState(DrawerLayout.java:834)
    at android.support.v4.widget.DrawerLayout$ViewDragCallback.onViewDragStateChanged(DrawerLayout.java:2089)
    at android.support.v4.widget.ViewDragHelper.setDragState(ViewDragHelper.java:881)
    at android.support.v4.widget.ViewDragHelper$2.run(ViewDragHelper.java:338)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:470)
    at android.support.test.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:365)
    at android.support.test.espresso.contrib.DrawerActions$DrawerAction.perform(DrawerActions.java:79)
    at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:144)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:211)
    at android.app.ActivityThread.main(ActivityThread.java:5389)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)

Below is the test that i am runnning:

@RunWith(AndroidJUnit4.class)
@LargeTest
public class AppNavigationTests {

    /**
     * {@link ActivityTestRule} is a JUint {@link Rule @Rule} to launch your activity under test
     * <p>
     * <p>
     * Rules are interceptios which are executed for each test method and are important building
     * block for JUnit tests.
     */

    @Rule
    public ActivityTestRule<HomeActivity> mActivityTestRule =
            new ActivityTestRule<>(HomeActivity.class);
    private IdlingResource mIdlingResource;



    @Test
    public void clickOnAndroidHomeIcon_OpensNavigation() {
        //check the left drawer is closed at startUp
        onView(withId(R.id.drawerlayout))
                .check(matches(isClosed(Gravity.LEFT))); //left Drawer should be closed
        //open Drawer
        onView(withContentDescription(TestUtils.getToolbarNavigationContentDescription(
                mActivityTestRule.getActivity(), R.id.toolbar
        )))
                .perform(click());

        //Check if drawer is open by now
        onView(withId(R.id.drawerlayout))
                .check(matches(isOpen(Gravity.LEFT)));

        //close the drawer
        onView(withContentDescription(TestUtils.getToolbarNavigationContentDescription(
                mActivityTestRule.getActivity(), R.id.toolbar
        ))).perform(click());
    }

    @Test
    public void clickGovNavigationItem_ShowsGovActivity() {
        //open drawer
        onView(withId(R.id.drawerlayout))
                .check(matches(isClosed(Gravity.LEFT))) //left drawer should be closed
                .perform(open());
        //start the gov Screen
        onView(withId(R.id.navigation_view))
                .perform(navigateTo(R.id.action_gov));

        //check that the Gov Activity was opened
        onView(withId(R.id.gov_frag_frame))
                .check(matches(isDisplayed()));
    }

}

回答1:


It sounds like ProGuard is removing one of the interfaces that is needed. I think you need to add a line like the following to your Proguard config:

-keep public interface android.support.test.espresso.IdlingResource$ResourceCallback {*;}

I don't have a way to test it at the moment, so if that's not quite right and you need to tweak it, here's a link to the Proguard manual for the "keep" options: http://proguard.sourceforge.net/manual/usage.html#keepoverview



来源:https://stackoverflow.com/questions/39841341/java-lang-nosuchmethoderror-no-interface-method-ontransitiontoidlev

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!