install and run an app on multiple devices with a single click under eclipse

前端 未结 5 1386
无人及你
无人及你 2021-02-12 14:43

I am wondering if there is a way to install and run an android application on multiple devices/emulator with a single click under Eclipse.

When I am testing a layout on

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-12 15:16

    I just finished the script Aleadam advice me to do.

    A simple loop on each device connected to the computer with install and start.

    Script andinstall:

    #!/bin/bash
    
    if [ $# -lt 3 ] ;then
        echo "usage $0 pathToTheFileToInstall packagename fullPackageActivityName"
        exit 1
    fi
    
    FILEPATH=$1
    PACKAGE=$2
    ACTIVITYNAME=$3
    
    APK=`ls $FILEPATH/*.apk`
    
    installOnSingleDevice(){
        echo "Installing on $DEVICE -------"
        echo "adb -s $1 install -r $APK"
        adb -s $1 install -r $APK 
    
        echo "adb -s $1 shell am start -n $2/$3"
        adb -s $1 shell am start -n $2/$3
        echo "--------------------------"
    }
    
    if [ $? -eq 0 ] ;then
        adb devices | grep device | grep -v attached | cut -f 1 > tmpfile
        while read line; 
        do 
            installOnSingleDevice $line $PACKAGE $ACTIVITYNAME&
        done < tmpfile
        rm tmpfile
    else
        echo "No apk at this path (${FILEPATH})"
    fi
    

    Usage example:

    andinstall ~/workspace/myapp/bin/ fr.openium.myapp fr.openium.myapp.activity.ActivitySplash
    

提交回复
热议问题