Android的 - 问题上使用Ubuntu和ADB设备100's安装应用 [英] android - Problems installing apps on 100´s of devices using Ubuntu and ADB

查看:284
本文介绍了Android的 - 问题上使用Ubuntu和ADB设备100's安装应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm新的论坛,我希望我把我的问题在正确的位置。

I´m new to the forum and I hope I placed my Question in the correct place.

我写了使用Ubuntu 14.04和Android调试桥自动配置Android智能手机的100's一些脚本。
为了实现我用了一个udev规则,以确定如果USB设备连接到PC,如果这就是我把我的脚本来安装一些应用程序到设备的情况。

I had written some scripts using Ubuntu 14.04 and Android Debug Bridge to automatically configure 100´s of Android Smartphones. To achieve that I used an udev rule to identify if an USB device is attached to the pc and if thats the case i call my scripts to install some apps onto the devices.

到目前为止,一切都不错,但也存在一些问题。
目前,我们正在同时连接5台设备,但它往往是在没有beeing安装一个或多个应用程序的设备之一发生。
它doesn't遵循一个模式,它只是发生随机。
有时也将计算机的性能在白天降低。

So far, so good but there are some problems. At the moment we are connecting 5 devices at the same time, but it happens quite often that on one of the devices one ore more apps are not beeing installed. It doesn´t follow a pattern, it just happens randomly. Sometimes also the performance of the computer decreases during the day.

我会强烈AP preciate你的帮助。
我希望描述是可以理解的,请原谅我的不好englisch。

I would highly appreciate your help. I hope the description is understandable and please forgive me for my bad englisch.

下面是/etc/udev/rules.d中在我的udev规则

Here is my udev rules in /etc/udev/rules.d

ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}!="1d6b", ATTRS{idVendor}!="203a", ATTRS{idVendor}=="****", ATTRS{idProduct}=="****", RUN+="/usr/local/bin/selectDevices.sh"

在/ usr / local / bin中第一个脚本/识别巫婆上应安装应用程序的设备

The first script in /usr/local/bin/ to identify the devices on witch the apps should be installed

#!/bin/bash

sleep 2
Pid=/home/android/Schreibtisch/PID

for DEVICE in `adb devices | tail -n +2 | grep device | awk '{print $1}'`;
do

  if [ ! -f $Pid/$DEVICE.pid ];
  then

    touch $Pid/$DEVICE.pid
    sh /usr/local/bin/touchDevices.sh $DEVICE

  fi

done

和最后的脚本安装应用

#!/bin/bash
cd /home/android/Desktop/Apps

for APK in $(ls *.apk);
do
    adb -s $1 install $APK
done

编辑1:
从来就尝试过像亚历克斯P.建议,或在他的回答我的间pretation。
通过串行到TMP脚本和TMP脚本是在现在呼吁与实际的安装脚本。安装脚本开始前,可容纳2秒。
但仍然存在的问题。梅比我需要登录发生了什么,而安装但此刻我不知道该怎么做。

Edit 1: I´ve tried it like Alex P. suggested it or in my interpretation of his answer. Pass the serial to a tmp script and the tmp script is calling the actual installation script with at now. Before the installation script starts it sleeps 2 seconds. But the Problems still exist. Maybee I need to log whats happening while installation but at the moment I have no clue how to do that.

编辑2:
一段时间后,我觉得我找到了,但我仍然不知道为什么。
我认为,亚行的问题时,两个设备需要同时安装一个应用程序。我设法它接收像的错误消息RM失败/data/local/tmp/foo.apk,没有这样的文件或目录
从那以后,我switcht先包拷贝到设备,然后与外壳包管理器进行安装,但仍然没有解决。

Edit 2: After some time I think I found something but I still have no idea why. I think adb has problems when two devices want to install one app at the same time. I Managed it to receive an error message like rm failed for /data/local/tmp/foo.apk, No such file or directory. After that I switcht to first copy the Package to the devices and then install them with the shell package manager, but still no solution.

推荐答案

我运行配置为自动运行 ADB多个Linux系统 FASTBOOT 上处理数百每天的Andr​​oid设备连接的顺利设备枚举命令。根据我的经验,我对你有以下建议:

I run multiple linux systems configured to automatically run adb and fastboot commands on device enumeration which process hundreds of Android device connections per day without a hitch. Based on my experience I have the following advice for you:


  • 您应前设备枚举后等待几秒钟
    发送任何亚行命令

  • 您不应该直接从的udev 规则运行任何长期运行的进程。您可以使用在现在命令脱钩论是你的 ADB安装从的udev 命令code>

  • you should wait couple of seconds after device enumeration before sending any adb commands
  • you should not run any long running processes directly from udev rule. You can use at now command to "decouple" your adb install commands from udev

此外


  • 有没有必要使用 ADB设备来获取序列号。让你的的udev 规则,把它提供给你的脚本作为参数。<​​/ li>
  • 它有助于更​​大的数字(90+)分配给您的的udev 规则

  • 没有必要使用庆典,其中 SH 足够

  • 使用完整路径尽可能

  • there is no need to use adb devices to get the serial number. Let your udev rule to provide it to your script as a parameter.
  • it helps to assign bigger number (90+) to your udev rule
  • no need to use bash where sh is enough
  • use full paths where possible

RUN + =打电话给你的安装脚本/ bin / sh的/full/path/to/the/script.sh $ ENV {} ID_SERIAL_SHORT

APKDIR="/full/path/to/apks"
PIDDIR="/full/path/to/pid"
ADB="/full/path/to/adb -s $1"

if [ ! -f $PIDDIR/$1.pid ]; then
    touch $PIDDIR/$1.pid
    CMD="sleep 5"
    for APK in $APKDIR/*.apk; do CMD="$CMD; $ADB install $APK"; done
    echo "$CMD" | at -M now 2>/dev/null
fi

如果仍然试图增加睡眠持续时间不稳定。甚至尝试一个随机数:

If still unstable try increasing the sleep duration. Or even try a random number:

CMD="sleep $(shuf -i 4-10 -n 1)"

这篇关于Android的 - 问题上使用Ubuntu和ADB设备100's安装应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆