2015-06-13 29 views
1

以下是我的AndroiManifest.xml:MonkeyRunner無法使用startActivity

<?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> 

我想用monkeyrunner啓動我的應用程序,但是當我發出命令

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

它不會啓動我的應用程序。我錯過了什麼。我讀Issues using monkeyrunner startActivity,但它仍然沒有工作。

回答

0

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

你嘗試固定錯字(〔實施例,而不是實施例)?

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

您是否嘗試過device.startActivity(component ='com.exmaple.helloworld/.MainActivity')?

0

你應該在清單更改活動名稱,來源:

android:name=".MainActivity" 

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

那麼你的腳本將工作。

0

添加android:exported="true"行爲AndroidManifest.xml文件中的activity