Android Monkey:"没有发现任何活动,猴子流产"

ncr*_*cus 10 android android-monkey

我的包名为com.mywebsite.banana.

  • 我想要种子,所以测试是可重复的:-s 13
  • 我希望有一个相当低级别的冗长:-v
  • 我想运行500 psuedo-random命令:500

我这样叫猴子:

adb shell monkey -s 13 -p com.mywebsite.banana -v 500
Run Code Online (Sandbox Code Playgroud)

我的输出:

:Monkey: seed=13 count=500
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
No activities found to run, monkey aborted
Run Code Online (Sandbox Code Playgroud)

我的AndroidManifest.xml中有这个:

<categoy android:name="android.intent.category.LAUNCHER"/>
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?在运行猴子之前,我需要在应用程序中添加一些内容吗?主要活动位于com.mywebsite.banana中 - 是传递的正确路径,还是应该一直到这样的活动:com.mywebsite.banana.activityName?

从我所读到的,似乎我正确地做到了这一点:


编辑

尝试1:

adb shell monkey -p com.mywebsite.banana -c intent.CATEGORY_LAUNCHER -v 500
Run Code Online (Sandbox Code Playgroud)

结果1:

:Monkey: seed=13 count=500
:AllowPackage: com.mywebsite.banana
:IncludeCategory: intent.CATEGORY_LAUNCHER  
// Warning: no activities found for category intent.CATEGORY_LAUNCHER
** No activities found to run, monkey aborted
Run Code Online (Sandbox Code Playgroud)

尝试2:

adb shell monkey -p com.mywebsite.banana -c android.intent.category.MONKEY -v 500
Run Code Online (Sandbox Code Playgroud)

结果2:

:Monkey: seed=13 count=500
:AllowPackage: com.mywebsite.banana
:IncludeCategory: android.intent.category.MONKEY 
No activities found to run, monkey aborted
Run Code Online (Sandbox Code Playgroud)

尝试3:

adb shell monkey -p com.mywebsite.banana -c android.intent.category.LAUNCHER -c android.intent.category.MONKEY -v 500
Run Code Online (Sandbox Code Playgroud)

结果3:

:Monkey: seed=13 count=500
:AllowPackage: com.mywebsite.banana
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY 
No activities found to run, monkey aborted
Run Code Online (Sandbox Code Playgroud)

一些清单:

<activity
        android:name="com.mywebsite.banana.FRCActivity"
        android:launchMode="singleTask"
        android:configChanges="orientation|screenSize"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="none" />
            <category android:name="android.intent.category.MONKEY"/>
        </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

还试过这个版本的清单,没有变化:

    <activity
        android:name="com.mywebsite.banana.FRCActivity"
        android:launchMode="singleTask"
        android:configChanges="orientation|screenSize"
        android:label="@string/app_name" >
        <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>
</activity>
Run Code Online (Sandbox Code Playgroud)

ncr*_*cus 13

好!我想通了.显示的错误确实是正确的:

** No activities found to run, monkey aborted
Run Code Online (Sandbox Code Playgroud)

这意味着我使用的包名称不正确.我凝视着,凝视着,盯着看,最后我的同事提到我们的构建系统在将其推送到设备之前更改了包的名称

因此,如果您收到此错误,请确保您确实知道您的包的名称是什么.

所以,最终的命令是这样的:

$ adb shell monkey -p com.mywebsite.banana.newname -v 5
Run Code Online (Sandbox Code Playgroud)

顺便说一句,这个monkey命令的正确输出如下所示:

:Monkey: seed=1418671144561 count=5
:AllowPackage: com.mywebsite.banana.newname
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Event percentages:
//   0: 15.0%
//   1: 10.0%
//   2: 2.0%
//   3: 15.0%
//   4: -0.0%
//   5: 25.0%
//   6: 15.0%
//   7: 2.0%
//   8: 2.0%
//   9: 1.0%
//   10: 13.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.mywebsite.banana.newname/com.mywebsite.banana.MyActivity;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.mywebsite.banana.newname/com.mywebsite.banana.MyActivity } in package com.mywebsite.banana.newname
Events injected: 5
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=175ms (0ms mobile, 0ms wifi, 175ms not connected)
// Monkey finished
Run Code Online (Sandbox Code Playgroud)

最后一点说明:我不需要添加android.intent.category.MONKEY到我的AndroidManifest.xml文件中!

  • 作为提示,您可以使用以下命令找到设备上应用程序的软件包名称:“adb shell pm list packages -3”(-3 将列表限制为第三方应用程序,除非您在 Google/Android/a 工作)设备制造商,您的可能是第三方应用程序:) (3认同)