Android Shell脚本在推送到设备时不工作
我想要什么 我想删除一些带有shell脚本的google应用程序,该脚本使用adb从我的windows客户端启动 问题出在哪里 当我使用adb/shell在命令提示符中使用以下命令时,它可以工作Android Shell脚本在推送到设备时不工作,android,shell,adb,Android,Shell,Adb,我想要什么 我想删除一些带有shell脚本的google应用程序,该脚本使用adb从我的windows客户端启动 问题出在哪里 当我使用adb/shell在命令提示符中使用以下命令时,它可以工作 pm uninstall --user 0 com.google.android.apps.maps 但是,当我将相同的命令放入shell脚本时,将其推送到我的手机上并尝试运行它-这会导致应用程序未安装错误 我通过一些变通办法解决了这个问题。 我只是从批处理中启动pm uninstall命令,而不是将
pm uninstall --user 0 com.google.android.apps.maps
但是,当我将相同的命令放入shell脚本时,将其推送到我的手机上并尝试运行它-这会导致应用程序未安装错误 我通过一些变通办法解决了这个问题。 我只是从批处理中启动pm uninstall命令,而不是将其推送到设备上 像这样:(uninstall.bat)
在Windows系统上创建的脚本包含MS-DOS/Windows样式的换行符(即
\r\n
)。Android shell使用Linux风格的换行符(\n
)。因此,您的脚本在每一行的末尾都会有一个额外的\r
字符,并且
pm卸载--用户0 com.google.android.apps.maps
变成pm卸载--用户0 com.google.android.apps.maps\r
您的脚本尝试卸载名为com.google.android.apps.maps\r
的包,该包不存在
要解决此问题,您需要在使用
sed-i的/\r$/'script.sh
命令将脚本推送到手机后,从脚本中删除所有这些\r
。但是,当我直接从命令提示符下尝试时,它为什么会起作用呢?我刚刚重写了问题。所以现在更容易理解:-)
adb shell pm uninstall --user 0 com.google.android.gm
adb shell pm uninstall --user 0 com.google.android.apps.maps
adb shell pm uninstall --user 0 com.google.android.youtube
pause