【问题标题】:Error running helloworldtest from the tutorial从教程中运行 helloworldtest 时出错
【发布时间】:2010-05-26 14:13:59
【问题描述】:

每当我尝试运行测试时,都会收到以下错误。我也尝试加载一些样本并对其进行测试,但我得到了同样的错误。

这是根据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)

【问题讨论】:

    标签: android testing android-activity android-intent resolve


    【解决方案1】:

    可能是在您的测试类的构造函数中,您有以下代码:

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

    代替这段代码:

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

    ?

    我刚刚遇到了类似的问题,这就是它的解决方案。

    【讨论】:

    • 谢谢,这帮助我解决了同样的问题。看起来通常它需要是项目的包,而不是您正在测试的类的子包。
    【解决方案2】:

    也许 SDK 没有正确设置?尝试重新安装 Android SDK (http://developer.android.com/sdk/index.html)

    【讨论】:

    • 更新:我一直在使用 SDK 平台 2.1-update1,API7,修订版 2。我更改为最新版本(SDK 平台 2.2,API 8,修订版 1)并且它工作。现在可以这样做,但我的目标是运行 2.1 的实际手机,所以这仍然是一个问题。
    猜你喜欢
    • 2017-04-23
    • 2012-12-13
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    • 2013-09-01
    • 1970-01-01
    • 2011-03-31
    • 1970-01-01
    相关资源
    最近更新 更多