Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 测试Android应用程序-猴子中止_Java_Android_Xml_Testing_Monkey - Fatal编程技术网

Java 测试Android应用程序-猴子中止

Java 测试Android应用程序-猴子中止,java,android,xml,testing,monkey,Java,Android,Xml,Testing,Monkey,我正在尝试使用monkey测试一些Android应用程序。但使用Monkey进行测试已经证明并不总是那么直观,因为它并不像人们所期望的那样开箱即用。我甚至读到,其他一些人也遇到了类似的问题,尽管这样做并没有明确解决问题 因此,为了运行Monkey,我将启动器包括在AndroidManifest.xml中: <intent-filter> <action android:name="android.intent.action.MAIN" />

我正在尝试使用monkey测试一些Android应用程序。但使用Monkey进行测试已经证明并不总是那么直观,因为它并不像人们所期望的那样开箱即用。我甚至读到,其他一些人也遇到了类似的问题,尽管这样做并没有明确解决问题

因此,为了运行Monkey,我将启动器包括在AndroidManifest.xml中:

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
然后,我还将MONKEY添加到AndroidManifest中:

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.MONKEY" />
</intent-filter>
同样地,我尝试了另一个,结果也一样:

$ adb shell monkey -p lunarlander.client -v 3
:Monkey: seed=1398537535683 count=3
:AllowPackage: lunarlander.client
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
** No activities found to run, monkey aborted.

但它仍然不起作用。您有什么想法或建议吗?

您应该使用包名作为
-p
的参数

因此,您的命令应该类似于:

adb shell monkey -p com.example.android.lunarlander -v 3
上面,
com.example.android.lunarlander
,是SDK附带的lunarlander包名


有关更多详细信息,请参阅。希望这有帮助。

太棒了!非常感谢。使用方法defaultConfig(applicationId)下的build.gradle文件中写入的packe名称可以实现这一目的
$ adb shell monkey -p lunarlander.client -v 3
:Monkey: seed=1398537535683 count=3
:AllowPackage: lunarlander.client
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
** No activities found to run, monkey aborted.
adb shell monkey -p com.example.android.lunarlander -v 3