android adb 局域网调试

自己新建一个app工程,设置adb连接

public class MainActivityextends AppCompatActivity{

    @Override

protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        openAdb();

}

    private void openAdb() {

        int port= 5555;

        Runtime.getRuntime().exec("su");

        Runtime.getRuntime().exec("setprop service.adb.tcp.port " + port);

        Runtime.getRuntime().exec("stop adbd");

        Runtime.getRuntime().exec("start adbd");

}

然后在studio中执行

adb connect 192.168.10.5:5555,ip是局域网中设备的ip

你可能感兴趣的:(android adb 局域网调试)