adb 启动命令,pc启动两个微信,INSTALL_FAILED_CONFLICTING_PROVIDER

本文介绍了解决在Android设备上因ContentProvider冲突导致的应用安装失败问题的方法。通过使用ADB命令获取冲突详情,并卸载冲突应用,使调试应用得以正常安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

rm -rf /storage/usbotg/*
 

清空文件

adb 下载链接

https://dl.google.com/android/repository/platform-tools-latest-windows.zip

adb kill-server
  在关闭adb服务后,要使用如下的命令启动adb服务。
  adb start-server

 电脑启动两个微信

进入安装目录下。cmd

The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER  错误

解决方法 

1所示就是冲突的authorities.2所示是自定义xml目录下的provider存储路径。(属于四大组件的ContentProvider知识),复制1内容

cmd执行下面adb命令——txt文件位置可选 

adb shell dumpsys package providers > C:\Users\TY\Desktop\abc.txt
 

执行完命令后,打开桌面的abc.txt,然后在文本文件里面,找到刚刚复制的冲突的authorities内容。

从而在文本中找到冲突的包名,卸载这个包名的apk。就能安装调试的apk了

执行ADB

public class CmdUtils {

    private static final String TAG = "CmdUtils";
    public static boolean excuseCMD(String command) {
        Process process = null;
        DataOutputStream os = null;
        try {
            //TODO 这里,执行su是向系统请求root权限,process是返回执行su的这个独立进程。
            process = Runtime.getRuntime().exec("su");
            os = new DataOutputStream(process.getOutputStream());
            os.writeBytes(command + "\n");
            //TODO Linux exit命令用于退出目前的shell
            os.writeBytes("exit\n");
            os.flush();
            process.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        close(os);
        process.destroy();
        return true;
    }

    public static String getState(Context context,String command) {
        String result = "";
        DataOutputStream dos = null;
        DataInputStream dis = null;
        try {
            Process p = Runtime.getRuntime().exec("su");// 经过Root处理的android系统即有su命令
            dos = new DataOutputStream(p.getOutputStream());
            dis = new DataInputStream(p.getInputStream());
            dos.writeBytes(command + "\n");  //查询名字为processName的进程id
            dos.flush();
            Thread.sleep(2000);
            while (dis.available() > 0) {
                result += dis.readLine() + "\n";
//                Toast.makeText(context,result,Toast.LENGTH_LONG).show();
            }
            Log.d(TAG, result);
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
        } finally {
            if (dos != null) {
                try {
                    dos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (dis != null) {
                try {
                    dis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return result;
    }

    private static void close(Object o) {
        if (o instanceof Closeable) {
            try {
                ((Closeable) o).close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值