2013-01-11 22 views
16

मेरे पास एक साधारण एंड्रॉइड ऐप है और मैं अपने फोन का उपयोग करके इसका परीक्षण कर रहा हूं। तो, वहाँ ऐसा करने के लिए दो तरीके हैं:android.util.AndroidException: INSTRUMENTATION_FAILED:

  1. ग्रहण
  2. का उपयोग CLI
  3. का उपयोग

समस्या:

जब मैं इकाई परीक्षण मामले ग्रहण का उपयोग कर चलाते हैं, तो यह मेरे फोन पर एप्लिकेशन इंस्टॉल रनटाइम पर और जूनिट टेस्ट रन करें और उसके बाद यदि मैं सीएलआई पर कमांड का उपयोग करता हूं: adb -d shell am instrument -w com.abc.xyz.test/android.test.InstrumentationTestRunner, यह ठीक चलता है।

हालांकि, अगर मैं सीधे पहला ग्रहण में इकाई परीक्षण मामलों चलने के बिना CLI में उपरोक्त आदेश चलाने के लिए, मैं हो रही है त्रुटि:

 
android.util.AndroidException: INSTRUMENTATION_FAILED: com.abc.xyz.test/android.test.InstrumentationTestRunner 
     at com.android.commands.am.Am.runInstrument(Am.java:586) 
     at com.android.commands.am.Am.run(Am.java:117) 
     at com.android.commands.am.Am.main(Am.java:80) 
     at com.android.internal.os.RuntimeInit.finishInit(Native Method) 
     at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:263) 
     at dalvik.system.NativeStart.main(Native Method) 
INSTRUMENTATION_STATUS: id=ActivityManagerService 
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation target package: com.abc.xyz 
INSTRUMENTATION_STATUS_CODE: -1 

AndroidManifest.xml शामिल हैं:

android:name="android.test.InstrumentationTestRunner" 
    android:targetPackage="com.abc.xyz" 

    inside instrumentation tag 

सका कृपया कोई मेरी मदद करें

उत्तर

23

मुझे लगता है कि आप इसे जनवरी से हल कर लेंगे, लेकिन मैं कमांड लाइन उपकरण के साथ काम करता हूं, इसी तरह की समस्या मिली (त्रुटि संदेश differen है टी) और इसे हल किया जैसे मैं निम्नलिखित चरणों में समझाता हूं। मैं एक सफल परीक्षण चलाने तक अपने खाली परीक्षण के साथ एक डमी परियोजना बनाने से पूरी प्रक्रिया करता हूं।मुझे आशा है कि यह किसी के लिए उपयोगी हो सकता है:

प्रथम चरण, प्रोजेक्ट बनाने:,

android create test-project 
    --path MyExampleTest 
    --name MyExampleTest 
    --main ../MyExample 

तीसरा कदम:

android create project 
    --name MyExample 
    --target "Google Inc.:Google APIs:17" 
    --path MyExample 
    --package com.example 
    --activity MyExampleActivity 

दूसरा कदम परीक्षण परियोजना बनाने के लिए, अपनी प्रोजेक्ट निर्देशिका तक पहुंच, इसे बनाएं और जांचें कि प्रक्रिया सफलतापूर्वक समाप्त हो जाती है:

cd MyExample && ant debug 

चौथा कदम, एमुलेटर को इसे स्थापित:

adb -s emulator-5554 install -r bin/MyExample-debug.apk 

पांचवें कदम, अपने परीक्षण परियोजना निर्देशिका के लिए उपयोग और परीक्षण चलाने के लिए प्रयास करें:

cd ../MyExampleTest && 
adb shell am instrument -w com.example.tests/android.test.InstrumentationTestRunner 

कि उपज:

INSTRUMENTATION_STATUS: id=ActivityManagerService 
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.example.tests/android.test.InstrumentationTestRunner} 
INSTRUMENTATION_STATUS_CODE: -1 
android.util.AndroidException: INSTRUMENTATION_FAILED: com.example.tests/android.test.InstrumentationTestRunner 
     at com.android.commands.am.Am.runInstrument(Am.java:676) 
     at com.android.commands.am.Am.run(Am.java:119) 
     at com.android.commands.am.Am.main(Am.java:82) 
     at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) 
     at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235) 
     at dalvik.system.NativeStart.main(Native Method) 

छठी कदम, अपने उपकरण clases सूची और सुनिश्चित करें कि अपने वर्तमान परियोजना याद आ रही है:

adb shell pm list instrumentation 

मेरी मशीन की पैदावार में यही:

instrumentation:com.android.emulator.connectivity.test/android.test.InstrumentationTestRunner (target=com.android.emulator.connectivity.test) 
instrumentation:com.android.emulator.gps.test/android.test.InstrumentationTestRunner (target=com.android.emulator.gps.test) 
instrumentation:com.android.example.spinner.tests/android.test.InstrumentationTestRunner (target=com.android.example.spinner) 
instrumentation:com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner (target=com.android.smoketest) 
instrumentation:com.android.smoketest.tests/android.test.InstrumentationTestRunner (target=com.android.smoketest) 
instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis) 

आप देख सकते हैं, com.example.tests नहीं करता है के लिए उपकरण अस्तित्व में नहीं है, इसलिए हमें इसे बनाना होगा।

सातवीं कदम, आप परियोजना का परीक्षण का निर्माण और जाँच कि इसे सफलतापूर्वक किया:

ant debug 

आठवें कदम, यह एमुलेटर को स्थापित:

adb -s emulator-5554 install -r bin/MyExampleTest-debug.apk 

नौवीं कदम, अपने उपकरण वर्गों की सूची बनाएं और अपनी परियोजना में से एक को देखें:

adb shell pm list instrumentation 

पैदावार कि: दूसरी पर

instrumentation:com.android.emulator.connectivity.test/android.test.InstrumentationTestRunner (target=com.android.emulator.connectivity.test) 
instrumentation:com.android.emulator.gps.test/android.test.InstrumentationTestRunner (target=com.android.emulator.gps.test) 
instrumentation:com.android.example.spinner.tests/android.test.InstrumentationTestRunner (target=com.android.example.spinner) 
instrumentation:com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner (target=com.android.smoketest) 
instrumentation:com.android.smoketest.tests/android.test.InstrumentationTestRunner (target=com.android.smoketest) 
instrumentation:com.example.tests/android.test.InstrumentationTestRunner (target=com.example) 
instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis) 

देखो पिछले, instrumentation:com.example.tests, यह जो हम चाहता था।

दसवीं कदम, चलाने के लिए अपनी परीक्षण:

adb shell am instrument -w com.example.tests/android.test.InstrumentationTestRunner 

पैदावार कि:

Test results for InstrumentationTestRunner= 
Time: 0.0 

OK (0 tests) 

सब है। अब अपने परीक्षणों को लागू करें, संकलित करें और सामान्य रूप से इंस्टॉल करें।इसके अतिरिक्त आप उन्हें पसंद निकाल सकते हैं:

adb shell pm uninstall com.example.tests 

लेकिन आप उपकरण कक्षाएं फिर से बनाने के लिए एक ही गलती से बचने के लिए की आवश्यकता होगी।

आपदोनों परीक्षण और एप्लिकेशन निर्देशिका से से

adb install -r bin/<>-debug.apk 

करना सुनिश्चित करें:

+0

धन्यवाद, धन्यवाद की स्थापना रद्द करने के बाद परीक्षण शुरू करें कि आप Birei धन्यवाद! इंस्टॉल कार्रवाई ने मेरी समस्या हल की, क्योंकि यही वजह है कि मुझे "उपकरण जानकारी खोजने में असमर्थ" त्रुटि मिली थी – gsaslis

+0

मैंने आपके रास्ते से जांच की लेकिन यह बिल्कुल काम नहीं कर रहा था। और एक और बात छठी चरण में मैं अपने प्रोजेक्ट का नाम इंस्ट्रूमेंटेशन सूची में देख पा रहा हूं लेकिन जब मैं परीक्षण चलाने की कोशिश कर रहा हूं तो यह ऊपर वर्णित जैसा त्रुटि देता है। क्रिप्या मेरि सहायता करे। –

+0

क्या आपने ग्रेडल के समान कुछ किया है? – c3rin

2

एक और अधिक सटीक विवरण/दृष्टिकोण पीछा कर रहा है।

उसके बाद ant test परीक्षण निर्देशिका से काम करना चाहिए। (मेरा अनुमान है कि परीक्षण पैकेज से ऐप के लिए एक लापता निर्भरता थी - जो विफलता का कारण बन रही थी)।

उपरोक्त छोटे हैक के अलावा, मैंने जो भी प्रक्रिया का पालन किया, वह http://developer.android.com/ पर एंड्रॉइड परीक्षण परिचय से आया।

1

, सुनिश्चित करें कि आप पिछले एप्लिकेशन स्थापना रद्द करें और पुनर्स्थापित या केवल पिछले एप्लिकेशन