2010-05-26 54 views
0

每當我嘗試運行測試時,都會收到以下錯誤消息。我也嘗試加載一些樣本並測試它們,但是我得到了同樣的錯誤。從教程運行helloworldtest時出錯

這會產生以下教程發現here

感謝所有幫助

java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=ca.imt.helloandroid.HelloAndroid/ca.imt.helloandroid.HelloAndroid } 
at android.app.Instrumentation.startActivitySync(Instrumentation.java:371) 
at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:120) 
at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:98) 
at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:87) 
at ca.imt.helloandroid.test.HelloAndroidTest.setUp(HelloAndroidTest.java:24) 
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430) 
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) 

回答

0

也許SDK ins't設置正確?嘗試重新安裝了Android SDK(http://developer.android.com/sdk/index.html

+0

更新:我一直在使用SDK平臺2.1-update1,API7,修訂版2. 我更改爲最新版本(SDK平臺2.2,API 8,修訂版1)並且工作正常。這會做現在,但我瞄準的實際電話運行2.1,所以這仍然是一個問題。 – paul 2010-05-26 15:40:18

1

難道是在您的測試類的構造函數,你有下面的代碼:

public HelloAndroidTest() { 
    super("com.example.helloandroid.HelloAndroid", HelloAndroid.class); 
} 

,而不是驗證碼:

public HelloAndroidTest() { 
    super("com.example.helloandroid", HelloAndroid.class); 
} 

我剛碰到類似的問題,那就是它的解決方案。

+0

謝謝,這幫助我解決了同樣的問題。也看起來像一般它需要是項目的包,而不是你正在測試的類的子包。 – sosiouxme 2010-10-30 03:58:01

相關問題