Java 错误=无法找到以下的检测信息:ComponentInfo{}
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21294945/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error=Unable to find instrumentation info for: ComponentInfo{ }
提问by mikeestrada67
I am trying to stand up espresso tests but I keep getting this error:
我正在尝试进行浓缩咖啡测试,但我不断收到此错误:
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.mikeestrada.test/android.test.InstrumentationTestRunner}
It worked once, but I can't get the reports to recreate correctly. They are just blank, didn't test anything. I've tried a plethora of commands including
它工作过一次,但我无法正确重新创建报告。他们只是空白,没有测试任何东西。我尝试了很多命令,包括
adb shell am instrument -w -r com.mikeestrada.test/android.test.InstrumentationTestRunner
and
和
adb shell am instrument -w -r com.mikeestrada.test/com.google.android.apps.common.testing.testrunner.GoogleInstrumentation TestRunner
Here are my code snippets:
这是我的代码片段:
AndroidManifest.xml
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.myapplication.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<instrumentationandroid:name="com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
android:targetPackage="com.mikeestrada.test"/>
TestStartScreen.java
测试开始屏幕.java
package com.mikeestrada.test;
import android.test.ActivityInstrumentationTestCase2;
import android.test.ActivityUnitTestCase;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.view.View;
import com.example.myapplication.MainActivity;
import com.example.myapplication.R;
import com.google.android.apps.common.testing.ui.espresso.Espresso;
import com.google.android.apps.common.testing.ui.espresso.ViewAssertion;
import com.google.android.apps.common.testing.ui.espresso.ViewInteraction;
import com.google.android.apps.common.testing.ui.espresso.action.ViewActions;
import com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions;
import com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers;
import junit.framework.Assert;
import org.hamcrest.Matcher;
public class TestStartScreen extends ActivityInstrumentationTestCase2<MainActivity> {
public TestStartScreen() {
super(MainActivity.class);
}
@LargeTest
public void testHelloWorld(final Matcher<View> viewMatcher) {
// Find
//ViewInteraction button1 = onView(ViewMatchers.withId(R.id.button1)); // Find the button
ViewInteraction helloWorldText = Espresso.onView(ViewMatchers.withText("Hello world!")); // Find the text
// Action
//button1.perform(ViewActions.click()); // Click the button
helloWorldText.perform(ViewActions.typeText("Bye World!"));
Espresso.onView(ViewMatchers.withText(R.id.withText));
// Check
helloWorldText.check(ViewAssertions.matches((ViewMatchers.isDisplayed()))); // Hello world text is hidden
//Espresso.onView(withId(R.id.my_view)).check(matches(withText("Hello world!")));
}
}
build.gradle
构建.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
assets.srcDirs = ['assets']
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
instrumentTestCompile files('libs/espresso-1.1-bundled.jar')
}
android {
defaultConfig {
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
}
task wrapper (type: Wrapper) {
gradlerVersion = '1.9'
}
If it means anything - the attributes of <instrumentation>
in the manifest are colored red as if IntelliJ does not recognize them.
如果这意味着什么 -<instrumentation>
清单中的属性被涂成红色,就好像 IntelliJ 无法识别它们一样。
Any help is great, thanks!
任何帮助都很棒,谢谢!
回答by IgorGanapolsky
You need to check which instrumentation packages have been installed on your device:
您需要检查您的设备上安装了哪些检测包:
adb shell pm list instrumentation
Then verify whether com.mikeestrada.testis actually listed there.
然后验证com.mikeestrada.test是否真的列在那里。
回答by paynd
Also, looks like yours app package is com.mikeestrada
.
So in AndroidManifest set android:targetPackage
as android:targetPackage="com.mikeestrada"
.
此外,看起来您的应用程序包是com.mikeestrada
. 所以在 AndroidManifest 中设置android:targetPackage
为android:targetPackage="com.mikeestrada"
.
I hope this will help.
我希望这将有所帮助。
回答by Marc Thomas
Looking at your build.gradle file, the problem is actually that you don't have the following configuration in the defaultConfig section:
查看你的 build.gradle 文件,问题其实是你的 defaultConfig 部分没有如下配置:
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
Espresso requires GoogleInstrumentationTestRunner
in order to work.
浓缩咖啡需要GoogleInstrumentationTestRunner
为了工作。
Also with a gradle build system you shouldn't need an AndroidManifest.xml
for the test project because it is auto generated.
同样使用 gradle 构建系统,您不应该需要AndroidManifest.xml
测试项目的 ,因为它是自动生成的。
回答by korosmatick
回答by Omar Madbouli
The issue is that you are missing a space:
问题是您缺少一个空格:
instrumentationandroid:name
should be
应该
instrumentation android:name