如何使用dockerfile在仿真器上构建和运行android apk [英] how to build and run android apk on emulator using dockerfile
本文介绍了如何使用dockerfile在仿真器上构建和运行android apk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想结帐该项目,并通过毕业生创建其apk,并在Windows上生成其apk,然后在仿真器上运行该apk。
所有这些我想通过脚本使用dockerfile做的事情,以便它创建一个图像。
这是我的dockerfile
FROM java:8
ENV DEBIAN_FRONTEND noninteractive
#依赖关系
RUN dpkg --add-architecture i386&& apt-get update&& apt-get install -yq libsdl1.2debian:i386 zlib1g:i386 libncurses5:i386 ant maven --no-install-recommendations
ENV GRADLE_URL http://services.gradle.org/distributions/gradle-2.2.1- all.zip
RUN curl -L $ {GRADLE_URL} -o /tmp/gradle-2.2.1-all.zip&& unzip /tmp/gradle-2.2.1-all.zip -d / usr / local&&& rm /tmp/gradle-2.2.1-all.zip
ENV GRADLE_HOME /usr/local/gradle-2.2.1
#下载并解压缩SDK
ENV ANDROID_SDK_URL http:// dl。 google.com/android/android-sdk_r24.1.2-linux.tgz
RUN curl -L$ {ANDROID_SDK_URL}| tar --no-same-owner -xz -C / usr / local
ENV ANDROID_HOME / usr / local / android-sdk-linux
ENV ANDROID_SDK / usr / local / android-sdk-linux
ENV PATH $ {ANDROID_HOME} / tools:$ ANDROID_HOME / platform-tools:$ PATH
#安装Android SDK组件
ENV ANDROID_SDK_COMPONENTS工具,平台工具,android-22,build-tools-22.0 .1,sys-img-armeabi-v7a-android-22,extra-android-m2repository,extra-google-m2repository
RUN echo y | android update sdk --no-ui --all --filter$ {ANDROID_SDK_COMPONENTS}--force
#创建模拟器
RUN echono| android创建avd \
--force \
--name test \
--target android-22 \
--abi armeabi-v7a \
--skin WVGA800 \
--sdcard 512M
CMD模拟器-avd测试-force-32bit
#支持Gradle
ENV TERM dumb
ENV JAVA_OPTS - Xms256m -Xmx512m
请让我知道如何做到这一点。
解决方案
如果我明白你的想法是什么:
- 这个命令的
github
的android项目是git clone --bare https://youurl.org/user/repo。 git
- 通过gradle build
创建其apk,命令为gradlew android:installDebug android:run
-
在Android的emulator
上运行该命令,该命令是从SDK的工具/目录
在仿真器上安装.apk:adb install< path_to_your_bin> .apk
adb -s emulator-path安装路径/到/ your / app.apk
I have a android application on github account. I want to checkout that project and create its apk through gradle and generate its apk on windows .And then run that apk on emulator. All these things I want to do through script using dockerfile so that it creates an image.
This is my dockerfile
FROM java:8
ENV DEBIAN_FRONTEND noninteractive
# Dependencies
RUN dpkg --add-architecture i386 && apt-get update && apt-get install -yq libsdl1.2debian:i386 zlib1g:i386 libncurses5:i386 ant maven --no-install-recommends
ENV GRADLE_URL http://services.gradle.org/distributions/gradle-2.2.1-all.zip
RUN curl -L ${GRADLE_URL} -o /tmp/gradle-2.2.1-all.zip && unzip /tmp/gradle-2.2.1-all.zip -d /usr/local && rm /tmp/gradle-2.2.1-all.zip
ENV GRADLE_HOME /usr/local/gradle-2.2.1
# Download and untar SDK
ENV ANDROID_SDK_URL http://dl.google.com/android/android-sdk_r24.1.2-linux.tgz
RUN curl -L "${ANDROID_SDK_URL}" | tar --no-same-owner -xz -C /usr/local
ENV ANDROID_HOME /usr/local/android-sdk-linux
ENV ANDROID_SDK /usr/local/android-sdk-linux
ENV PATH ${ANDROID_HOME}/tools:$ANDROID_HOME/platform-tools:$PATH
# Install Android SDK components
ENV ANDROID_SDK_COMPONENTS tools,platform-tools,android-22,build-tools-22.0.1,sys-img-armeabi-v7a-android-22,extra-android-m2repository,extra-google-m2repository
RUN echo y | android update sdk --no-ui --all --filter "${ANDROID_SDK_COMPONENTS}" --force
# Create emulator
RUN echo "no" | android create avd \
--force \
--name test \
--target android-22 \
--abi armeabi-v7a \
--skin WVGA800 \
--sdcard 512M
CMD emulator -avd test -force-32bit
# Support Gradle
ENV TERM dumb
ENV JAVA_OPTS -Xms256m -Xmx512m
Please let me know how to do this.
解决方案
If I understand you questions what you want is:
- Check out the android project from
github
for this the command isgit clone --bare https://youurl.org/user/repo.git
- Create its apk through gradle build
for this the command is
gradlew android:installDebug android:run
Run that apk on android emulator for this the command is, from your SDK's
tools/ directory
, install the .apk on the emulator:adb install <path_to_your_bin>.apk adb -s emulator-path install path/to/your/app.apk
这篇关于如何使用dockerfile在仿真器上构建和运行android apk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文