如何防止calabash-android“App没有启动”错误?

时间:2013-09-04 11:15:13

标签: android ruby linux calabash

我在linux pc上工作,

确保AndroidManifest.xml具有INTERNET权限。 尝试使用和不使用代理命令,观察是相同的。

我的真实设备有4.1.1安卓软件,

AVD拥有4.2.2安卓,API等级为17,这会有问题吗?

我观察到,示例演示应用程序在设备上启动,而我运行'calabash-android运行AndroidDemoProject.apk ... 但是命令抛出错误,说“App没有启动”(RunTimeError)。

错误详情:

Feature: Demo feature

  Scenario: I can start my app                             # features/my_first.feature:3
    I wait for "Hello World, AndroidDemoProject" to appear
3707 KB/s (553745 bytes in 0.145s)
3045 KB/s (36301 bytes in 0.011s)
  App did not start (RuntimeError)
  /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:512:in `start_test_server_in_background'
  /usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:31:in `perform'
  /usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:59:in `retriable'
  /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:511:in `start_test_server_in_background'
  /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:92:in `start_test_server_in_background'
  /home/vijayvk/Downloads/AndroidDemoProject/calabash/features/support/app_life_cycle_hooks.rb:15:in `Before'

Failing Scenarios:
cucumber features/my_first.feature:3 # Scenario: I can start my app
I wait for "Hello World, AndroidDemoProject" to appear

1 scenario (1 failed)
0 steps
0m22.337s
===========================================================================

$calabash-android run ../AndroidDemoProject.apk --verbose, leads to below output

013-09-04 15:42:45 - /usr/bin/ruby1.8 -S cucumber --verbose MAIN_ACTIVITY=sh.calaba.demoproject.AndroidDemoProjectActivity APP_PATH="/home/vijayvk/Downloads/AndroidDemoProject/AndroidDemoProject.apk" TEST_APP_PATH="test_servers/d06f94e698e2dfae7d59f229087ea78f_0.4.9.apk"
Code:
  * features/support/env.rb
  * features/support/app_installation_hooks.rb
  * features/support/app_life_cycle_hooks.rb
  * features/support/hooks.rb
  * features/step_definitions/calabash_steps.rb

Features:
  * features/my_first.feature
Parsing feature files took 0m0.002s


Feature: Demo feature

  Scenario: I can start my app                             # features/my_first.feature:3
    I wait for "Hello World, AndroidDemoProject" to appear
2013-09-04 15:42:46 - First scenario in feature - reinstalling apps
2013-09-04 15:42:46 - "/home/vijayvk/Development/adt-bundle-linux-x86-20130219/sdk/platform-tools/adb" -s 00000D6300009613 forward tcp:34777 tcp:7102
2013-09-04 15:42:46 -
2013-09-04 15:42:46 - Uninstalling: sh.calaba.demoproject.test
2013-09-04 15:42:47 - Success
2013-09-04 15:42:47 - Uninstalling: sh.calaba.demoproject
2013-09-04 15:42:49 - Success
2013-09-04 15:42:49 - Installing: test_servers/d06f94e698e2dfae7d59f229087ea78f_0.4.9.apk
3153 KB/s (553745 bytes in 0.171s)
2013-09-04 15:42:54 -     pkg: /data/local/tmp/d06f94e698e2dfae7d59f229087ea78f_0.4.9.apk
Success
2013-09-04 15:42:55 - Installing: /home/vijayvk/Downloads/AndroidDemoProject/AndroidDemoProject.apk
4513 KB/s (36306 bytes in 0.007s)
2013-09-04 15:42:56 -     pkg: /data/local/tmp/AndroidDemoProject.apk
Success
2013-09-04 15:42:59 - Waking up device using:
2013-09-04 15:42:59 - "/home/vijayvk/Development/adt-bundle-linux-x86-20130219/sdk/platform-tools/adb" -s 00000D6300009613 shell am start -a android.intent.action.MAIN -n sh.calaba.demoproject.test/sh.calaba.instrumentationbackend.WakeUp
Starting: Intent { act=android.intent.action.MAIN cmp=sh.calaba.demoproject.test/sh.calaba.instrumentationbackend.WakeUp }
2013-09-04 15:43:01 - Starting test server using:
2013-09-04 15:43:01 - "/home/vijayvk/Development/adt-bundle-linux-x86-20130219/sdk/platform-tools/adb" -s 00000D6300009613 shell am instrument -e class sh.calaba.instrumentationbackend.InstrumentationBackend -e target_package sh.calaba.demoproject -e test_server_port 7102 -e main_activity sh.calaba.demoproject.AndroidDemoProjectActivity -e debug false sh.calaba.demoproject.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner

  App did not start (RuntimeError)
  /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:512:in `start_test_server_in_background'
  /usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:31:in `perform'
  /usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:59:in `retriable'
  /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:511:in `start_test_server_in_background'
  /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:92:in `start_test_server_in_background'
  /home/vijayvk/Downloads/AndroidDemoProject/calabash/features/support/app_life_cycle_hooks.rb:15:in `Before'

Failing Scenarios:
cucumber features/my_first.feature:3 # Scenario: I can start my app
I wait for "Hello World, AndroidDemoProject" to appear

1 scenario (1 failed)
0 steps
0m26.737s
==========================================================================

$ calabash-android console AndroidDemoProject/AndroidDemoProject.apk

No test server found for this combination of app and calabash version. Recreating test server.
Done signing the test server. Moved it to test_servers/d06f94e698e2dfae7d59f229087ea78f_0.4.9.apk

irb(main):004:0> ARGV << "-v"
[
    [0] "--readline",
    [1] "--prompt-mode",
    [2] "simple",
    [3] "-v"
]
irb(main):005:0> start_test_server_in_background
2013-09-04 16:29:06 - Starting test server using:
2013-09-04 16:29:06 - "/home/vijayvk/Development/adt-bundle-linux-x86-20130219/sdk//platform-tools/adb" -s 00000D6300009613 shell am instrument -e test_server_port 7102 -e class sh.calaba.instrumentationbackend.InstrumentationBackend -e debug false -e target_package sh.calaba.demoproject -e main_activity sh.calaba.demoproject.AndroidDemoProjectActivity sh.calaba.demoproject.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner
RuntimeError: App did not start
    from /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:512:in `start_test_server_in_background'
    from /usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:31:in `perform'
    from /usr/lib/ruby/gems/1.8/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:59:in `retriable'
    from /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:511:in `start_test_server_in_background'
    from /usr/lib/ruby/gems/1.8/gems/calabash-android-0.4.9/lib/calabash-android/operations.rb:92:in `start_test_server_in_background'
    from (irb):5

如果有任何解决此问题的工作,请告诉我......

3 个答案:

答案 0 :(得分:3)

当我遇到这个错误时,我可以解决这个问题:

1)关闭AVD并重新启动

2)如果(1)没有解决问题,请卸载该应用,然后再次为您的应用执行reinstall_apps

3)如果(2)没有解决问题,请删除测试服务器文件夹并再次执行start_test_server_in_background。

答案 1 :(得分:0)

添加以下内容也可以解决问题。

<uses-permission android:name="android.permission.INTERNET" />

参考: http://www.luisdelarosa.com/2013/04/18/how-to-fix-problem-when-app-wont-start-when-testing-with-calabash-android/

答案 2 :(得分:0)

你也可以尝试这种方式。 在ruby文件夹中找到文件operations.rb。路径就像这样&#34; C:\ Ruby23-x64 \ lib \ ruby​​ \ gems \ 2.3.0 \ gems \ calabash-android-0.7.3 \ lib \ calabash-android&#34;。打开文件,找到代码块:

    Retriable.retriable :tries => 100, :interval => 0.1 do
              raise "App did not start" unless app_running?

改变&#34;尝试&#34;参数值在300而不是100.它将帮助您的应用程序在设备效率不高的情况下运行。 我们已经使用默认设置测试了6种不同的设备,但只有2款旗舰智能手机(三星Galaxy S6)才可以运行应用程序&#34;尝试&#34;参数值=&gt; 100。 现在我们所有的设备都可以运行应用程序了!