我是 Docker 的新手,需要在仪器测试方面寻求帮助。我创建了一个 Dockerfile(从 这里获取并做了一些小的修改)。
FROM ubuntu:14.04
# Install java7
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:webupd8team/java && \
(echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections) && \
apt-get update && \
apt-get install -y oracle-java7-installer && \
apt-get clean && \
rm -fr /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV JAVA7_HOME /usr/lib/jvm/java-8-oracle
# Install java8
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:webupd8team/java && \
(echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections) && \
apt-get update && \
apt-get install -y oracle-java8-installer && \
apt-get clean && \
rm -fr /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV JAVA8_HOME /usr/lib/jvm/java-8-oracle
# Install Deps
RUN dpkg --add-architecture i386 && apt-get update && apt-get install -y -- force-yes expect git wget libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1 libpulse0 python curl libqt5widgets5 && apt-get clean && rm -fr /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Copy install tools
COPY tools /opt/tools
RUN chmod +x /opt/tools/android-accept-licenses.sh
RUN chmod +x /opt/tools/android-wait-for-emulator.sh
ENV PATH ${PATH}:/opt/tools
# Install Android SDK
RUN cd /opt && wget --output-document=android-sdk.tgz --quiet https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz && \
tar xzf android-sdk.tgz && \
rm -f android-sdk.tgz && \
chown -R root.root android-sdk-linux && \
/opt/tools/android-accept-licenses.sh "android-sdk-linux/tools/android update sdk --all --no-ui --filter platform-tools,tools" && \
/opt/tools/android-accept-licenses.sh "android-sdk-linux/tools/android update sdk --all --no-ui --filter platform-tools,tools,build-tools-25.0.2,android-14,android-23,android-25,extra-android-support,extra-android-m2repository,extra- google-m2repository,extra-google-google_play_services,sys-img-armeabi-v7a- google_apis-23"
# Setup environment
ENV ANDROID_HOME /opt/android-sdk-linux
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
RUN which adb
RUN which android
# Create emulator
RUN echo "no" | android create avd \
--force \
--device "Nexus 5" \
--name nexus5_23 \
--target android-23 \
--abi google_apis/armeabi-v7a \
--sdcard 512M
# Cleaning
RUN apt-get clean
# Start up the emulator
RUN ["/bin/bash", "-c", "SHELL=/bin/bash emulator -avd nexus5_23 -no-window & /opt/tools/android-wait-for-emulator.sh"]
# GO to workspace
RUN mkdir -p /opt/workspace
WORKDIR /opt/workspace
当我构建它时,它可以正常工作,并且模拟器运行。 我的Bitbucket管道是
image: xxx/android-23:latest
pipelines:
default:
- step:
script:
- bash ./gradlew cAT
但是我的所有管道都出现了错误:
com.android.builder.testing.api.DeviceException: 没有连接的设备!
是否可以自动运行仪器测试?也许我不应该使用Docker,而应该使用其他东西?