Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一个Project如果有多个APP,无法选择APP #9

Open
FrederickHuuu opened this issue Dec 28, 2022 · 2 comments
Open

一个Project如果有多个APP,无法选择APP #9

FrederickHuuu opened this issue Dec 28, 2022 · 2 comments

Comments

@FrederickHuuu
Copy link

比如一个
RootDirectoryApps/App1
RootDirector/Apps/App2
这两个应用,那么在远程编译的时候,无法选择编译运行哪个

@hi-dhl
Copy link
Owner

hi-dhl commented Dec 30, 2022

收到,我处理一下

@zzyyppqq
Copy link

zzyyppqq commented May 4, 2023

可以添加-p参数指定app目录,assembleDebug -p App1
image

修改install-apk.sh,解析-p参数对应的App1

#!/bin/sh
SYNC_DIR=$(cd $(dirname $0);cd ..; pwd)
PROJECT_DIR=$(cd $(dirname $0); cd ..;cd ..; pwd)
echo "SYNC_DIR: $SYNC_DIR"
echo "PROJECT_DIR: $PROJECT_DIR"
CONFIG_JSON_PATH=$SYNC_DIR/service/config.json
echo "CONFIG_JSON_PATH: $CONFIG_JSON_PATH"
appName=""
# 通过config.json获取应用-p参数,从而按照指定应用
# 需安装 apt install jq
function app_name() {
    command=$(cat $CONFIG_JSON_PATH | jq '.remoteBuildCommand' | sed 's/\"//g')
    echo "command: $command"
    params='-p'
    if [[ $command =~ $params ]]
    then
        array=(`echo $command | tr ',' ' '` )
        len=${#array[@]}
        for var in ${array[@]}
        do
           echo "--> $var"
           appName=$var
        done
        echo "len: $len"
    else
        echo "无-p参数"
    fi
}

app_name
echo "appName: $appName"

apkFindPath=""
if [ "$appName" ]
then
   apkFindPath=${PROJECT_DIR}/${appName}
 else
    apkFindPath=.
fi
echo "apkFindPath: $apkFindPath"

launchActivity=$1
echo "launchActivity: $launchActivity"
find  $apkFindPath -name "*.apk" | while read fname; do
  echo $fname
#  -r : 覆盖原来安装的 APK 并保留数据
  adb install -r -t $fname
  if [ "$launchActivity" ]; then
    adb shell am start $launchActivity
  fi
  break
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants