Selendroid不会启动一些应用程序

时间:2021-12-19 20:53:17

I got the average setup for starting an app on a device and sometimes it works perfectly fine (the app starts and can be controlled by selendroid) sometimes (in the case of the firefox.apk) this happens:

我得到了在设备上启动一个应用程序的平均设置,有时它运行得非常好(应用程序启动并可以由selendroid控制),有时(在firefox.apk的例子中)这种情况会发生:

Aug 10, 2015 3:02:13 PM io.selendroid.standalone.io.ShellCommand exec
INFORMATION: Executing shell command: C:\Users\Dustin Altermann\AppData\Local\Android\sdk\platform-tools\adb.exe -s BX903DKMSR shell am instrument -e main_activity -e server_port 8080 io.selendroid.org.mozilla.firefox/io.selendroid.server.ServerInstrumentation
Aug 10, 2015 3:02:13 PM io.selendroid.standalone.io.ShellCommand exec
INFORMATION: Shell command output
-->
usage: am [subcommand] [options]
usage: am start [-D] [-W] [-P ] [--start-profiler ]
[--R COUNT] [-S] [--opengl-trace]
am startservice
am force-stop
am kill
am kill-all
am broadcast
am instrument [-r] [-e ] [-p ] [-w]
[--no-window-animation]
am profile start
am profile stop []
am dumpheap [flags]
am set-debug-app [-w] [--persistent]
am clear-debug-app
am monitor [--gdb ]
am screen-compat [on|off]
am display-size [reset|MxN]
am to-uri [INTENT]
am to-intent-uri [INTENT]

am start: start an Activity. Options are:
-D: enable debugging
-W: wait for launch to complete
--start-profiler : start profiler and send results to
-P : like above, but profiling stops when app goes idle
-R: repeat the activity launch times. Prior to each repeat,
the top activity will be finished.
-S: force stop the target app before starting the activity
--opengl-trace: enable tracing of OpenGL functions

am startservice: start a Service.

am force-stop: force stop everything associated with .

am kill: Kill all processes associated with . Only kills.
processes that are safe to kill -- that is, will not impact the user experience.

am kill-all: Kill all background processes.

am broadcast: send a broadcast Intent.

am instrument: start an Instrumentation. Typically this target is the form /. Options are:
-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT). Use with
[-e perf true] to generate raw output for performance measurements.
-e : set argument to . For test runners a
common form is [-e [,...]].
-p : write profiling data to
-w: wait for instrumentation to finish before returning. Required for test runners.
--no-window-animation: turn off window animations will running.

am profile: start and stop profiler on a process.

am dumpheap: dump the heap of a process. Options are:
-n: dump native heap instead of managed heap

am set-debug-app: set application to debug. Options are:
-w: wait for debugger when application starts
--persistent: retain this value

am clear-debug-app: clear the previously set-debug-app.

am monitor: start monitoring for crashes or ANRs.
--gdb: start gdbserv on the given port at crash/ANR

am screen-compat: control screen compatibility mode of .

am display-size: override display size.

am to-uri: print the given Intent specification as a URI.

am to-intent-uri: print the given Intent specification as an intent: URI.

specifications include these flags and arguments:
[-a ] [-d ] [-t ]
[-c [-c ] ...]
[-e|--es ...]
[--esn ...]
[--ez ...]
[--ei ...]
[--el ...]
[--ef ...]
[--eu ...]
[--ecn ]
[--eia [, [--ela [, [--efa [, [-n ] [-f ]
[--grant-read-uri-permission] [--grant-write-uri-permission]
[--debug-log-resolution] [--exclude-stopped-packages]
[--include-stopped-packages]
[--activity-brought-to-front] [--activity-clear-top]
[--activity-clear-when-task-reset] [--activity-exclude-from-recents]
[--activity-launched-from-history] [--activity-multiple-task]
[--activity-no-animation] [--activity-no-history]
[--activity-no-user-action] [--activity-previous-is-top]
[--activity-reorder-to-front] [--activity-reset-task-if-needed]
[--activity-single-top] [--activity-clear-task]
[--activity-task-on-home]
[--receiver-registered-only] [--receiver-replace-pending]
[--selector]
[ | | ]

Error: Bad component name: server_port
<--
Aug 10, 2015 3:02:13 PM io.selendroid.standalone.io.ShellCommand exec
INFORMATION: Executing shell command: C:\Users\Dustin Altermann\AppData\Local\Android\sdk\platform-tools\adb.exe -s BX903DKMSR forward tcp:8080 tcp:8080
Aug 10, 2015 3:02:13 PM io.selendroid.standalone.io.ShellCommand exec
INFORMATION: Shell command output
-->

<--
Aug 10, 2015 3:02:13 PM io.selendroid.standalone.android.impl.AbstractDevice startLogging
INFORMATION: starting logcat:
Aug 10, 2015 3:02:13 PM io.selendroid.standalone.server.model.SelendroidStandaloneDriver waitForServerStart
INFORMATION: Waiting for the Selendroid server to start.
Aug 10, 2015 3:02:13 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFORMATION: Checking if the Selendroid server is running: http://localhost:8080/wd/hub/status
Aug 10, 2015 3:02:13 PM org.apache.http.impl.execchain.RetryExec execute
INFORMATION: I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8080: Connection reset
Aug 10, 2015 3:02:13 PM org.apache.http.impl.execchain.RetryExec execute
INFORMATION: Retrying request to {}->http://localhost:8080
Aug 10, 2015 3:02:13 PM org.apache.http.impl.execchain.RetryExec execute
INFORMATION: I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8080: Connection reset
Aug 10, 2015 3:02:13 PM org.apache.http.impl.execchain.RetryExec execute
INFORMATION: Retrying request to {}->http://localhost:8080
Aug 10, 2015 3:02:13 PM org.apache.http.impl.execchain.RetryExec execute
INFORMATION: I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8080: Connection reset
Aug 10, 2015 3:02:13 PM org.apache.http.impl.execchain.RetryExec execute
INFORMATION: Retrying request to {}->http://localhost:8080
Aug 10, 2015 3:02:13 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFORMATION: Can't connect to Selendroid server, assuming it is not running.

The app doesn't start and selendroid keeps trying but nothing happens. I can start the app manually without any problems. I don't understand the difference or what to do to narrow down the problem.

这个应用程序没有启动,selendroid一直在尝试,但是什么也没有发生。我可以手动启动应用程序,没有任何问题。我不知道有什么不同,也不知道该做些什么来缩小问题的范围。

BTW.: I used the firefox.apk from the Google Play Store if anyone wants to try themselves.

顺便说一句。我用的是火狐浏览器。如果有人想尝试的话,可以去谷歌Play商店购买apk。

1 个解决方案

#1


1  

Ok I finally did it:

好吧,我终于做到了:

The problem was that this particular app had an AndroidManifest.xml file (read it by using e.g. https://code.google.com/p/xml-apk-parser/) using the tag "activity-alias". Inside this tag there were the fields that Selendroid needs to determine the so called "main_activity":

问题是这个特殊的应用程序有一个AndroidManifest。xml文件(使用例如https://code.google.com/p/xml-ap -parser/)使用标签“activity-alias”读取。在这个标记中,有Selendroid需要确定所谓的“main_activity”的字段:

<activity-alias android:label="Firefox" android:name=".App" android:targetActivity="org.mozilla.gecko.BrowserApp">
    <intent-filter android:priority="999">
        <action android:name="android.intent.action.MAIN">
        </action>
        <category android:name="android.intent.category.LAUNCHER">
        </category>
        <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER">
        </category>
        <category android:name="android.intent.category.DEFAULT">
        </category>
    </intent-filter>

Unfortunately Selendroid doesn't understand this tag and therefore cant find the "main_activity".

不幸的是,Selendroid不理解这个标记,因此不能找到“main_activity”。

Solution: I had to use the "SelendroidCapabilities.setLaunchActivity"-method to specifically tell Selendroid what activity to use:

解决方案:我必须使用“SelendroidCapabilities”。setLaunchActivity——专门告诉Selendroid使用什么活动的方法:

SelendroidCapabilities caps = new SelendroidCapabilities("org.mozilla.firefox:39.0");
caps.setLaunchActivity("org.mozilla.gecko.BrowserApp");

#1


1  

Ok I finally did it:

好吧,我终于做到了:

The problem was that this particular app had an AndroidManifest.xml file (read it by using e.g. https://code.google.com/p/xml-apk-parser/) using the tag "activity-alias". Inside this tag there were the fields that Selendroid needs to determine the so called "main_activity":

问题是这个特殊的应用程序有一个AndroidManifest。xml文件(使用例如https://code.google.com/p/xml-ap -parser/)使用标签“activity-alias”读取。在这个标记中,有Selendroid需要确定所谓的“main_activity”的字段:

<activity-alias android:label="Firefox" android:name=".App" android:targetActivity="org.mozilla.gecko.BrowserApp">
    <intent-filter android:priority="999">
        <action android:name="android.intent.action.MAIN">
        </action>
        <category android:name="android.intent.category.LAUNCHER">
        </category>
        <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER">
        </category>
        <category android:name="android.intent.category.DEFAULT">
        </category>
    </intent-filter>

Unfortunately Selendroid doesn't understand this tag and therefore cant find the "main_activity".

不幸的是,Selendroid不理解这个标记,因此不能找到“main_activity”。

Solution: I had to use the "SelendroidCapabilities.setLaunchActivity"-method to specifically tell Selendroid what activity to use:

解决方案:我必须使用“SelendroidCapabilities”。setLaunchActivity——专门告诉Selendroid使用什么活动的方法:

SelendroidCapabilities caps = new SelendroidCapabilities("org.mozilla.firefox:39.0");
caps.setLaunchActivity("org.mozilla.gecko.BrowserApp");