使用adb卸载多个android包

时间:2017-07-07 14:41:19

标签: android bash shell adb

我正在尝试使用带有adb uninstall的bash脚本卸载多个软件包。

理论上,遵循脚本应该有效:

$(function() {

  var colors = ['#FF0000', '#FF9900', '#009900'];
  var colorIterator = 0;
  var chart;

  $(document).ready(function() {
    const json = [{"data":[30.95]},{"data":[2.38]},{"data":[66.67]}]
    setTimeout(function() {
      chart = Highcharts.chart('container', {
        chart: {
          renderTo: 'container1',
          type: 'column',
          height: 200,
          marginRight: 25,
          marginBottom: 25,
          plotBackgroundColor: '#FCFFC5',
          style: {
            fontFamily: 'serif',
            fontSize: '8px',
          }
        },

        title: {
          text: '',
          x: -20,
          style: {
            fontFamily: 'Tahoma',
            color: '#000000',
            fontWeight: 'normal',
            fontSize: '11px'
          } //center
        },

        subtitle: {
          text: '',
        },

        xAxis: {
          categories: ['Detractors', 'Passives', 'Promoters'],
          title: {
            text: ''

          }
        },

        yAxis: {

          //reversedStacks: false,
          endOnTick: false,
          max: 101,
          showFirstLabel: false,
          lineColor: '#999',
          lineWidth: 1,
          tickColor: '#666',
          tickWidth: 1,
          tickLength: 2,
          tickInterval: 10,
          gridLineColor: '#ddd',
          title: {
            text: '',
            style: {
              fontFamily: 'Tahoma',
              color: '#000000',
              fontWeight: 'bold',
              fontSize: '8px'
            }
          },
          plotLines: [{
            color: '#808080'
          }]
        },

        credits: {
          enabled: false
        },

        tooltip: {
          formatter: function() {
            return '<b>Guest responses: ' + this.y + '<br/>' + this.series.name + '</b><br/>Month:' +
              this.x;
          }
        },



        navigation: {
          buttonOptions: {
            verticalAlign: 'top',
            y: -10,
            x: -20
          }
        },

        legend: {
          enabled: false,
          layout: 'vertical',
          align: 'right',
          verticalAlign: 'top',
          x: -10,
          y: 100,
          borderWidth: 1
        },

        colors: [
          '#FF0000',
          '#FF9900',
          '#009900',
        ],

        plotOptions: {
          column: {
            colorByPoint: false
          }
        },

        series: {
          type: 'column',
          cursor: 'pointer',
          pointWidth: 30,
          point: {
            events: {
            }
          },

          legendIndex: 0,

          dataLabels: {
            enabled: true,
            color: '#000000',
            align: 'center',
            cursor: 'pointer',
            y: -6,
            format: '{y:.2f} %', // one decimal
            y: -20, // 10 pixels down from the top
            style: {
              textShadow: false,
              fontSize: '8px',
              fontFamily: 'Verdana, sans-serif'
            }
          }
        },

        exporting: {
          chartOptions: { // specific options for the exported image
            plotOptions: {
              series: {
                dataLabels: {
                  enabled: true
                }
              }
            }
          },
          fallbackToExportServer: false
        },
        series: json,
      });
    });
  });
});

OR

adb shell pm list packages com.your.app |
cut -d ':' -f 2 | while read line ; do
  adb uninstall --verbose $line
done

我收到以下错误

  

失败[DELETE_FAILED_INTERNAL_ERROR]

我还发现问题在于adb命令没有从shell变量中获取管道参数或参数。例如,以下命令也

adb shell pm list packages com.your.app |
cut -d ':' -f 2 |
xargs -L1 -t adb uninstall

这也会产生同样的错误。

我已经查看了delete packages of domain by adb shell pm

1 个答案:

答案 0 :(得分:3)

\ r \ n添加到第一个命令的输出中。我们可以使用tr -d '\r'删除这些字符。

adb shell pm list packages com.your.app |
cut -d ':' -f 2 |
tr -d '\r' |
xargs -L1 -t adb uninstall

Echo outputting results in erratic order in BASH

中找到解决方案