0

I have a problem with eclipse (for java developers). I try to do an app, but when i select a java file and i click "run", Eclipse give me this error. I rename my app "AndroidFAQ". So, it appear this problem:

"AndroidFAQ does not specify a android.test.InstrumentationTestRunner instrumentation or does not declare uses-library android.test.runner in its AndroidManifest.xml".

Mark Rotteveel
110k241 gold badges160 silver badges233 bronze badges
asked Oct 26, 2013 at 12:20
4
  • Post code instead. Post your Manifest File and your activities. Commented Oct 26, 2013 at 12:23
  • I rename my app "AndroidFAQ" is this your error? Or what? Commented Oct 26, 2013 at 12:24
  • Hello. Welcome to SO. You may want to add more information (and possibly code) about this error, so that people can help you find the problem. Commented Oct 26, 2013 at 12:40
  • Excuseif I wrote something wrong... I don't know how add more information and code about this error... where are these errors, and these codes ? i want post a screenshot... so it would be easier... Commented Oct 26, 2013 at 13:19

1 Answer 1

2

Add to the AndroidManifest.xml the following -

<instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="..." android:label="..." />
<uses-library android:name="android.test.runner" />

Hope this helps.


Updated.

You can create a test project that its root directory tests/ was at the same level as the src/ directory in the main project. You can also create a new test project. This new project should have an explicit dependency on your main project. The wizard will create this and set it up correctly at the time you create the original project (if you click the checkbox)

 +Hello Android
 | |
 | +----+src
 | | |
 | ... |-+my.pkg.app
 | | |
 | | +-MainClass.java
 | |
 | ...
 | 
 |- AndroidManifest.xml
 ...
 |
 + Hello Android Test
 | |
 | +----+src
 | | |
 | ... +--+my.pkg.app.test
 | | |
 | ... +-MainTest.java
 | |
 | ... 
 |
 |- AndroidManifest.xml
 ... 

In this case AndroidManifest.xml file should look like as below:

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="my.pkg.app.test"
 android:versionCode="1"
 android:versionName="1.0">
 <application>
 <uses-library android:name="android.test.runner" />
 </application>
 <instrumentation android:name="android.test.InstrumentationTestRunner"
 android:targetPackage="my.pkg.app"
 android:label="Tests for my.pkg.app"/>
</manifest>

See also:

answered Oct 26, 2013 at 12:25
Sign up to request clarification or add additional context in comments.

3 Comments

I tried... But i don't know what i must write in android:targetPackage="..." android:label="..." />. I tried a lot, but eclipse give me an error...
Excuse me... but can you be more precise? Because i am a beginner... and i'm not english... So what i must put in "android:targetPackage=" and "android:label="? if i can talk you in private, because so i can send you a screenshot... thanks for help!
Thanks so much ... I tried but I do not work the same ... When I write what you told me tells me that there is an error in the XML ...

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.