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(); } } } }