java.lang.NoSuchMethodError:没有接口方法onTransitionToIdle()V [英] java.lang.NoSuchMethodError: No interface method onTransitionToIdle()V
问题描述
请我是Android测试的新手,我正在尝试修复初始的NavigationView测试,但我遇到了错误.我只是想打开抽屉,然后单击菜单以转到新活动.
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()));
}
}
推荐答案
听起来ProGuard正在删除所需的接口之一.我认为您需要在Proguard配置中添加以下内容:
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:
-保留公共接口android.support.test.espresso.IdlingResource $ ResourceCallback {*;}
-keep public interface android.support.test.espresso.IdlingResource$ResourceCallback {*;}
目前我还没有办法对其进行测试,因此,如果这还不太正确,并且您需要对其进行调整,那么这里有一个指向Proguard手册的保留"选项的链接: http://proguard.sourceforge.net/manual/usage.html#keepoverview
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
这篇关于java.lang.NoSuchMethodError:没有接口方法onTransitionToIdle()V的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!