のために機能しないため、Androidデバイスに複数のアプリケーションをアンインストールして再インストールする必要があります。すばやく行うには、これを行うためのスクリプトを書くのは簡単です。何度も繰り返し入力する必要はありません。adb uninstallコマンドがBashシェルのステートメント
奇妙なことは、「エコー」が正しいコマンドを出力している間、常に「失敗」を表示するということです。 コメントを外すと、2行目は正常に動作します。
誰でも問題の原因を突き止めるのに役立ちますか?
のために機能しないため、Androidデバイスに複数のアプリケーションをアンインストールして再インストールする必要があります。すばやく行うには、これを行うためのスクリプトを書くのは簡単です。何度も繰り返し入力する必要はありません。adb uninstallコマンドがBashシェルのステートメント
奇妙なことは、「エコー」が正しいコマンドを出力している間、常に「失敗」を表示するということです。 コメントを外すと、2行目は正常に動作します。
誰でも問題の原因を突き止めるのに役立ちますか?
'失敗しました' ...私はdos2unixを使ってこの同じ問題を回避しましたが、tr -d "\ r"の方が優れています。 すべてのadbシェルコマンドでMSDOS CRLFが追加されるわけではなく、一部の時間だけ追加されます。
#!/bin/bash
# By ESSPEE
# Initial Build: 23rd Dec, 2015
(
app=$(zenity --entry --text='Enter the application name (whatever you remember) :' --entry-text='facebook' --height=100 --width=450 --title="Uninstall Android Application");
filter=$(adb shell pm list packages | cut -d":" -f2 | grep -i "$app" | dos2unix);
counter=$(echo "$filter" | wc -l);
if [[ "`adb shell pm list packages | cut -d":" -f2 | grep -i "$app"`" == "" ]]; then
zenity --error --title="Uninstall Android Application" --text="No such application installed on the android device.\nEither it is not installed or you don't have permission.\n\n<b>=> It might be possible that you want to uninstall system\napplication and your device is not rooted.</b> " --no-wrap
exit 1
fi
if [[ "$counter" -eq 1 ]]; then
zenity --question --title="Application to be uninstalled" --text="You have selected $counter package to be uninstalled.\nDo you really want to uninstall :-\n\n<b><i>$filter</i></b>" --no-wrap
if [[ $? == 0 ]]; then
adb shell pm disable $filter
adb shell pm clear $filter
adb shell pm uninstall $filter
echo "10" ; sleep 1
echo "# $counter application being uninstalled from android device ..." ; sleep 1
else
exit 1
fi
elif [[ "$counter" -gt 1 ]]; then
zenity --question --title="$counter Application to be uninstalled" --text="<b>NOTICE:</b> You have selected $counter applications to be uninstalled.\nDo you really want to uninstall the following packages :-\n\n<b><i>$filter</i></b>" --no-wrap
if [[ $? == 0 ]]; then
echo "10" ; sleep 1
echo "# $counter Android applications being uninstalled from android device ..." ; sleep 1
for file in $filter ;
do
adb shell pm disable $file;
adb shell pm clear $file;
adb shell pm uninstall $file;
done
else
exit 1
fi
fi
notify-send --icon=/usr/share/icons/SSB/scalable/apps/apk.png "Uninstall Android Application" "$counter Applications uninstalled."
echo "100" ; sleep 1
) |
zenity --progress --pulsate --auto-close --title="Uninstall Android Application" --text="Application being uninstalled from android device ..." --width=500 --height=100
exit 0
次の例では、私は実装を紹介し、必要なDOS2UNIXコマンドです:
#!/bin/bash
####################################################################
# ADB Uninstall Util (GPL license, author: @hpsaturn)
#
# Dependencies: android-tools-adb, dos2unix
#
# Revision:
# -----------------------------------------------------------------
# 20171005 get package name (without execution)
# 20171019 filter for multiple apks and execution ready
####################################################################
pkg=`adb shell 'pm list packages -f' | sed -e 's/.*=//' | grep $1`
cnt=`echo "$pkg" | wc -l`
adb=`echo "$pkg" | sed -e 's/^/adb uninstall /'`
cmd=`echo "$adb" | dos2unix`
if [ "$pkg" = "" ]; then
echo "package not found!"
exit 1
elif (($cnt > 1)); then
echo ""
echo "multiple packages found:"
echo ""
echo "$pkg"
echo ""
else
echo "uninstalling: $pkg"
bash -c "$cmd"
fi
は私が今自分でそれに答えるましょう。パッケージ名には「\ r」があります。したがって、この文字を削除するには 'tr -d" \ r "'を使用してください。 –