gpt4 book ai didi

android - Travis CI Android 测试 : no connected devices

转载 作者:IT老高 更新时间:2023-10-28 21:52:54 27 4
gpt4 key购买 nike

我正在尝试为 Android 设置 Travis。到目前为止,运行构建似乎可以工作,但是在测试时,它会提示“没有连接的设备!”

:app:connectedAndroidTestDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:connectedAndroidTestDebug'.
> com.android.builder.testing.api.DeviceException: java.lang.RuntimeException:
No connected devices!

这是我的 .travis.yml,据我了解,我正在为测试创建并启动一个模拟器,就像 documentation 一样。说。

language: android
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - platform-tools
# - tools

# The BuildTools version used by your project
- build-tools-22.0.1

# The SDK version used to compile your project
- android-22

# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
# - addon-google_apis-google-19
# - add-on
# - extra

# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-armeabi-v7a-android-22
# - sys-img-x86-android-17

licenses:
- 'android-sdk-license-.+'

# Emulator Management: Create, Start and Wait
before_script:
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &

你能告诉我我做错了什么以及如何解决它吗?

最佳答案

不幸的是,我不允许发表评论,因为我只想完成 DominicJodoin 的回答。正如 DominicJodoin 所述,正确的缩进和更长的 ADB_INSTALL_TIMEOUT 是必要的。

在我看来,您的模拟器正在运行,但尚未准备好安装 apk。使用 - adb wait-for-device 等待设备连接。根据Documentation这意味着:

Note that this command does not cause adb to wait until the entire system is fully booted. For that reason, you should not prepend it to other commands that require a fully booted system.

尝试在 travis.yml 中用 - android-wait-for-emulator 替换这一行。

Travis.yml

language: android
jdk: oraclejdk7
cache:
directories:
- node_modules
sudo: false

android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - platform-tools
# - tools

# The BuildTools version used by your project
- build-tools-22.0.1

# The SDK version used to compile your project
- android-22

# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
# - addon-google_apis-google-19
# - add-on
# - extra

# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-armeabi-v7a-android-21
# - sys-img-x86-android-17

licenses:
- 'android-sdk-license-.+'

env:
global:
# install timeout in minutes (2 minutes by default)
- ADB_INSTALL_TIMEOUT=8

# Emulator Management: Create, Start and Wait
before_script:
- echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &

script:
- android list target
- ./gradlew connectedAndroidTest

关于android - Travis CI Android 测试 : no connected devices,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31264136/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com