Programing

두 개 이상의 에뮬레이터 / 기기가 연결된 경우 APK 파일을 설치할 수 있나요?

lottogame 2020. 9. 8. 21:50
반응형

두 개 이상의 에뮬레이터 / 기기가 연결된 경우 APK 파일을 설치할 수 있나요?


명령 프롬프트 등으로 에뮬레이터에 apk 파일을 설치하는 방법을 알고 있습니다. 하지만 특정 이름을 지정하여 여러 에뮬레이터에 동일한 apk 파일을 설치할 수 있는지 알고 싶습니다. 실제로 여러 장치에서 하나의 apk 파일을 테스트해야합니다. 이를 위해 많은 장치를 시작했습니다. 나는 그것을 설치하는 방법을 안다. 모든 장치가 열려 있으면 설치되지 않습니다. 따라서 특정 장치 에뮬레이터 ID 또는 이름을 제공하여 해당 apk 파일을 설치하는 대안이 있습니까? 그것에 대한 아이디어가 있으면 저를 도와주세요. . . 감사.


예, 특정 기기에 APK를 설치할 수 있습니다.

명령에서 다음을 입력하십시오.

adb devices
// list of devices and its unique ID...

그런 다음 다음을 입력하십시오.

adb -s "<deviceIDfromlist>" install "<path-to-apk>"

1 단계 : 기기에 연결된 모든 기기의 기기 ID 가져 오기

adb 장치

2 단계 : 설치하려는 특정 장치에 설치

adb -s deviceId 설치 경로 + apk

예:

1 단계:

C : \ Android \ android-sdks \ platform-tools> adb devices 연결된 장치 목록 emulator-5554 device 014FD87107021017 device

2 단계:

C : \ Android \ android-sdks \ platform-tools> adb -s 014FD87107021017 install C : \ Users \ user \ Documents \ appname.apk


연결된 모든 장치에서 동시에 설치 명령을 내릴 있습니다.

핵심은 adb별도의 프로세스 (&)에서 시작 하는 것입니다.

다음 스크립트를 작성하여 연결된 모든 장치에서 동시에 설치를 시작하고 마지막으로 각각에 설치된 응용 프로그램을 시작했습니다.

#!/bin/sh

function install_job { 

    adb -s ${x[0]} install -r PATH_TO_YOUR_APK
    adb -s ${x[0]} shell am start -n "com.example.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

}


#iterate over devices IP-addresses or serial numbers and start a job 

while read LINE
do
    eval x=($LINE)
    install_job ${x[0]} > /dev/null 2>&1 &
done <<< "`adb devices |  cut -sf 1`"

echo "WATING FOR INSTALLATION PROCESSES TO COMPLETE"
wait

echo "DONE INSTALLING"

Note 1: the STDOUT and STDERR are suppressed. You won't see any "adb install" operation result. This may be improved, I guess, if you really have to

Note 2: you could also improve script by providing args instead of hardcoded path and activity names.

That way you:

  1. Don't have to manually perform install on each device
  2. Don't have to wait for one install to finish in order to execute another one (adb tasks are launched in parallel)

Use the following scripts to install apk on multiple devices/emulators.

    for SERIAL in $(adb devices | grep -v List | cut -f 1);
    do adb -s $SERIAL install -r /path/to/product.apk;
    done

Remove -r if you are not reinstalling the apk. Also you can replace "install -r /path/to/product.apk" to other adb commands like working on one single device.

It works for me on real devices but I believe it should also works for emulators.


yes you can install your apk file in multiple emulator for that you have to give the name in command prompt here is the link for guidance

http://developer.android.com/guide/developing/tools/emulator.html


You can install on multiple devices at a time using USB debugging.

In Eclipse Run--> Run Configurations --> choose your project (on left) -->Target --> Launch on All compatible devices.

The selected project will be installed on all the connected devices

참고URL : https://stackoverflow.com/questions/7186215/is-it-possible-to-install-apk-file-if-more-than-one-emulators-devices-are-connec

반응형