adb uninstall <package name>
działa po podłączeniu 1 urządzenia.Jak użyć narzędzia adb do odinstalowania pliku APK z wielu podłączonych urządzeń?
Jak mogę to zrobić dla 5 urządzeń, które są podłączone?
adb uninstall <package name>
działa po podłączeniu 1 urządzenia.Jak użyć narzędzia adb do odinstalowania pliku APK z wielu podłączonych urządzeń?
Jak mogę to zrobić dla 5 urządzeń, które są podłączone?
Oto prosty skrypt używam do wykonania polecenia ADB nad wszystkimi moimi urządzeniami należy działa pod Linuxem i MacOsX.
Być może trzeba będzie dostosować go do swojego środowiska programistycznego.
#!/bin/bash
# Script adb+
# Usage
# You can run any command adb provide on all your current devices
# ./adb+ <command> is the equivalent of ./adb -s <serial number> <command>
#
# Examples
# ./adb+ version
# ./adb+ install apidemo.apk
# ./adb+ uninstall com.example.android.apis
adb devices | while read line
do
if [ ! "$line" = "" ] && [ `echo $line | awk '{print $2}'` = "device" ]
then
device=`echo $line | awk '{print $1}'`
echo "$device [email protected] ..."
adb -s $device [email protected]
fi
done
Przyjemny skrypt ;-) –
Otrzymuję komunikat o błędzie 'head: nielegalna liczba linii - -1' –
@SheehanAlam z jakiego używasz OS? wydaje się, że nie używasz polecenia head z GNU coreutils. – Rick
Należy napisać skrypt, który wywołuje funkcję adb kilka razy i przy każdym uruchomieniu określa numer seryjny każdego podłączonego urządzenia za pomocą przełącznika -s.
Alternatywą jest użycie Android Maven plugin, która może po prostu przejrzeć wszystkie podłączone urządzenia (lub tylko emulatory lub urządzenia). Zobacz i nteraction with devices chapter w książce Maven: The Complete Reference, którą napisałem.
także nie że wielu interakcji urządzenie wtyczki Maven Android działa również dla pchać, ciągnąć, instalacji i uruchamiania testów ..
Domyślam się, że skrypt został właśnie napisany przez Rabgsa dla ciebie ;-) –
Aby odinstalować pakiet po podłączeniu wielu urządzeń, można użyć następujących poleceń.
adb devices
Spowoduje to wyświetlenie listy podłączonych elementów.
List of devices attached
1234c112fsasfl device
53fsks22323233 device
192.168.56.101:5555 device
adb -s your_device_key uninstall your_package_name
.
$ adb -s 1234c112fsasfl uninstall com.test.sample
success - (if the device contains the apk with the specified package name)
failure - (if the device did not contain the apk with the specified package name)
W Java:
public class main {
private final static String packageName = "com.mypackage.xxx";
public static void main(String[] args) throws IOException, InterruptedException {
new main().doStuff();
}
private void doStuff() throws IOException, InterruptedException {
Runtime rt = Runtime.getRuntime();
String command = "adb devices -l";
Process pr = rt.exec(command);
ArrayList<HashMap<String, String>> devices = new ArrayList<HashMap<String, String>>();
BufferedReader bf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String l = "";
while ((l = bf.readLine()) != null) {
String[] res = l.split("\\s{2,}");
if (res.length == 2) {
HashMap<String, String> device = new HashMap<String, String>();
device.put("serial", res[0]);
device.put("name", res[1]);
devices.add(device);
}
}
String commandUninstall = "adb -s %s uninstall %s";
for (HashMap<String, String> map : devices) {
String serial = map.get("serial");
String finalCommanUnisntall = String.format(commandUninstall, serial, packageName);
System.out.println(finalCommanUnisntall);
Process pr2 = rt.exec(finalCommanUnisntall);
BufferedReader bf2 = new BufferedReader(new InputStreamReader(pr2.getInputStream()));
String l2 = "";
while ((l2 = bf2.readLine()) != null) {
System.out.println(l2);
}
}
}
}
zdaję sobie sprawę, że kwestia ta ma już zaakceptowane odpowiedź, ale:
for d in $(adb devices -l | sed '1d' | sed '$d' | awk '{print $1}'); do adb -s $d uninstall your.pkg.id.here; done
Pierwszy sub-polecenie:
Następnie zewnętrzna dla pętli:
Zabawne, zadałeś już to pytanie: http://stackoverflow.com/questions/8610733/how-can-i-adb-install-an-apk-to-multiple-connected-devices. To samo dotyczy innego polecenia. – aromero
to nie dlatego, że instalacja wymaga identyfikatora urządzenia, ponieważ odinstalowanie go nie powoduje. –