无法找到检测目标包:com.xyz [英] Unable to find instrumentation target package: com.xyz

查看:15
本文介绍了无法找到检测目标包:com.xyz的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一个库项目写了一个测试用例类,我单独创建了这个测试用例项目.

I wrote a testcase class for a library project,I created this test case project separately.

当我尝试运行此测试项目时,控制台显示错误无法找到检测目标包:<带有包名称>",

when I am trying to run this test project.the console is showing the error "Unable to find instrumentation target package: <with package name>",

我也在谷歌上搜索了解决方案,在一些网站中,他们检查了 AndroidManifestFile 中的标签 android:targetPackage 属性.

I google for the solution also,in some sites they gave check the tag android:targetPackage attribute in AndroidManifestFile .

我检查了清单,检测标签是正确的,它正确地定位到 libraryproject 包.

I checked the manifest the instrumentation tag is correct it is targeting correctly the libraryproject package.

任何人都可以在这方面提供帮助,使我的库测试用例项目可运行

Could any one help in this,to make my testcase project for a library runnable

推荐答案

您必须创建和设置依赖于库项目的应用程序项目,才能测试库项目.引用官方开发者指南:

You have to create and setup an Application Project that depends on the Library Project, in order to test the Library Project. Quoting from official developer's guide:

在库项目中设置代码和资源测试的推荐方法有两种:

Testing a Library Project

There are two recommended ways of setting up testing on code and resources in a library project:

  • 您可以设置一个测试项目来检测应用程序项目这取决于图书馆项目.然后,您可以将测试添加到库特定功能的项目.

  • You can set up a test project that instruments an application project that depends on the library project. You can then add tests to the project for library-specific features.

您可以设置一个依赖于库的标准应用程序项目,并将检测放在该项目中.这使您可以创建一个包含测试/仪器和要测试的代码的自包含项目.

You can set up a set up a standard application project that depends on the library and put the instrumentation in that project. This lets you create a self-contained project that contains both the tests/instrumentations and the code to test.

Android 库项目不是直接构建的,而是与主应用程序项目一起构建的.换句话说,您无法将其直接编译为自己的 .apk 并在 Android 设备上运行.另一方面,在设备上安装 app.apk 和 test.apk 后,仪器测试通过运行测试项目应用程序(Eclipse 中的Run As..."->Android JUnit Test"),然后使用 test.apk 来操作 app.apk——因此是测试名称的检测"部分.

Android Library Projects are not built directly, but are built along with the Main Application Project. In another words, you cannot compile it directly to its own .apk and run it on an Android device. On the other hand, instrumentation tests work by running the test project application ("Run As..."->"Android JUnit Test" in Eclipse) after installing both app.apk and test.apk on the device, and then using test.apk to manipulate the app.apk—hence the "instrumentation" part of the test name.

更新:

请注意,如果您使用第二种方法,您可以创建一个测试项目测试库项目,而无需创建第三个应用项目,因为测试项目本身也是一个常规的应用项目.

Note that if you use second approach, you can create a Test Project testing Library Project without creating a third Application Project, because a Test Project itself is also a regular Application Project.

这篇关于无法找到检测目标包:com.xyz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆