同时运行robotium错误消息已显示“没有与目标com.android.calculator2匹配的签名”

时间:2015-09-28 11:41:06

标签: robotium

这是我的代码

package com.test.android.calculator2;

import android.app.Activity;

import com.robotium.solo.Solo;

import android.test.ActivityInstrumentationTestCase2;

@SuppressWarnings("unchecked")

public class TestApk extends ActivityInstrumentationTestCase2 {

    private static final String TARGET_PACKAGE_ID="com.android.calculator2";
    private static final String
    LAUNCHER_ACTIVITY_FULL_CLASSNAME="com.android.calculator2.Calculator";

    private static Class <?> launcherActivityClass;
    static {
        try {
            Activity act = new Activity();
            launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
    // @SuppressWarnings("unchecked")

    public TestApk()throws ClassNotFoundException {
        super(TARGET_PACKAGE_ID,launcherActivityClass);
    }
    private Solo solo;
    @Override
    protected void setUp() throws Exception {
        solo = new Solo(getInstrumentation());
    }
    public void testCanOpenSettings() {
        solo.getActivityMonitor();
        getActivity();

        solo.sendKey(Solo.DOWN);
        solo.goBack();
    }

    @Override
    public void tearDown() throws Exception {
        try {
            solo.finalize();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        getActivity().finish();
        super.tearDown();
    }
}

像这样的清单文件

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.test.android.calculator2"

    android:versionCode="1"

    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="19" />

    <instrumentation

        android:name="android.test.InstrumentationTestRunner"
        android:targetPackage="com.android.calculator2" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <uses-library android:name="android.test.runner" />
    </application>

</manifest>

1 个答案:

答案 0 :(得分:0)

看起来无法找到您定义的目标包com.android.calculator2

我发现您发布的课程位于包com.test.android.calculator2

您必须创建新的包com.android.calculator2或将目标包设置为现有包(例如com.test.android.calculator2)。