MonkeyRunner unable to use startActivity

506 views Asked by At

The following is my AndroiManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.helloworld"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

I want to launch my app using monkeyrunner but when I give the command

device.startActivity(component='com.exmaple.helloworld/com.example.helloworld.MainActivity')

It doesn't start my app. Am I missing anything. I read Issues using monkeyrunner startActivity but still it didn't work.

4

There are 4 answers

0
Lyn On

Add android:exported="true" line for the activity in AndroidManifest.xml file

0
sagarwadhwa1 On

device.startActivity(component='com.exmaple.helloworld/com.example.helloworld.MainActivity')

have you tried fixing the typo (exmaple instead of example) ?

device.startActivity(component='com.example.helloworld/com.example.helloworld.MainActivity')
0
lookatcn On

Have you tried device.startActivity(component='com.exmaple.helloworld/.MainActivity')?

0
ivan.panasiuk On

You should change activity name in manifest, from:

android:name=".MainActivity"

to

android:name="com.example.helloworld.MainActivity"

then your script will work.