gpt4 book ai didi

android - 谷歌 Espresso java.lang.RuntimeException : Could not launch intent Intent { act=android. intent.action.MAIN

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:53:18 30 4
gpt4 key购买 nike

我是 Espresso UI 测试的新手。

我在运行测试时遇到这个错误(ADT Eclipse IDE)。

该应用程序已经开发完成,并且在启动该应用程序时有很多请求正在进行。无法重写应用程序。但我需要找到测试此 UI 的方法,即使组件加载有任何延迟也是如此。

        java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.xx.android/com.yy.core.android.map.MapActivity } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1390913271702 and and now the last time the queue went idle was: 1390913271767. If these numbers are the same your activity might be hogging the event queue.
at com.google.android.apps.common.testing.testrunner.GoogleInstrumentation.startActivitySync(GoogleInstrumentation.java:277)
at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:119)
at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:97)
at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:104)
at com.gulesider.android.test.UItest.setUp(UItest.java:25)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onStart(GoogleInstrumentationTestRunner.java:167)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1799)
  1. 我有一个名为“Core”的库项目 - 它不会生成任何 .apk
  2. 我还有一个名为“AA”的 Android 项目,它将访问“Core”。 - 这是 AA.apk
  3. 现在我已经创建了一个名为“UItest”的测试项目

list :

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AA.android.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="18" />
<instrumentation
android:name="com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
android:targetPackage="com.AA.android"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.core.android.map.MapActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="android.test.runner" />
</application>
</manifest>

我的测试:

    public class UItest extends ActivityInstrumentationTestCase2<MapActivity> {
public UItest() {
super(MapActivity.class);
}

@Override
public void setUp() throws Exception {
super.setUp();

getActivity();

}

public void testSearchBox() {

Espresso.onView(ViewMatchers.withId(R.id.menu_button_logo)).perform(ViewActions.click());

}

}

最佳答案

对于 Espresso 测试,强烈建议您关闭用于测试的虚拟或物理设备上的系统动画。因此,您可以按照以下步骤手动关闭动画:

在: 设置->
开发者选项-> 绘图

  1. 窗口动画缩放到关闭
  2. 将动画缩放转换为 OFF
  3. Animator duration scale to OFF

关于android - 谷歌 Espresso java.lang.RuntimeException : Could not launch intent Intent { act=android. intent.action.MAIN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21406246/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com