Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 浓缩咖啡-无法启动intent intent{act=android.intent.action.MAIN flg=0x14000000_Java_Android_Android Studio_Android Espresso - Fatal编程技术网

Java 浓缩咖啡-无法启动intent intent{act=android.intent.action.MAIN flg=0x14000000

Java 浓缩咖啡-无法启动intent intent{act=android.intent.action.MAIN flg=0x14000000,java,android,android-studio,android-espresso,Java,Android,Android Studio,Android Espresso,我正在尝试在android studio中用浓缩咖啡测试应用程序,但没有成功。我尝试了两天找到解决方案,但仍然得到了一个例外: ----- begin exception ----- E/TestRunner: java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.example.testoftest/.MainA

我正在尝试在android studio中用浓缩咖啡测试应用程序,但没有成功。我尝试了两天找到解决方案,但仍然得到了一个例外:

    ----- begin exception -----
E/TestRunner: java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.example.testoftest/.MainActivity } 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 1581611079968 and now the last time the queue went idle was: 1581611079968. If these numbers are the same your activity might be hogging the event queue.
        at androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:481)
        at androidx.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:358)
        at androidx.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:529)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runners.Suite.runChild(Suite.java:128)
        at org.junit.runners.Suite.runChild(Suite.java:27)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
        at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
        at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
        at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2154)
E/TestRunner: ----- end exception -----
这是我的格拉德尔:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.testoftest"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'androidx.test:rules:1.1.1'
    androidTestImplementation 'androidx.test:runner:1.1.1'

    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
    androidTestImplementation 'androidx.test.ext:truth:1.0.0'
}
这是我的androidTest:

package com.example.testoftest;


import androidx.test.rule.ActivityTestRule;


import org.junit.Rule;
import org.junit.Test;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withText;


public class MainActivityTest {
    //this rule can't start activity and fails
    @Rule
    public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class); 
    @Test
    public void view_isCorrect() {
        onView(withText("Hello World!")).check(matches(isDisplayed()));
    }
}
package com.example.testoftest;
导入androidx.test.rule.ActivityTestRule;
导入org.junit.Rule;
导入org.junit.Test;
导入静态androidx.test.espresso.espresso.onView;
导入静态androidx.test.espresso.assertion.ViewAssertions.matches;
导入静态androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
导入静态androidx.test.espresso.matcher.ViewMatchers.withText;
公共类维护活动测试{
//此规则无法启动活动,因此失败
@统治
public ActivityTestRule mActivityTestRule=新的ActivityTestRule(MainActivity.class);
@试验
公共无效视图\u isCorrect(){
onView(使用文本(“helloworld!”)。检查(匹配项(isDisplayed()));
}
}

我有一台8年的笔记本电脑,装有AMD A6-3400 APU处理器。可能是这样吗?因为例如,我无法在此CPU上运行android emulator。

您是否尝试过让任何其他
ActivityTestRule
aka activity启动?您有没有用这台机器运行过任何浓缩咖啡测试?不,很遗憾,我没有。