|
@@ -86,8 +86,12 @@ impl AppHandle {
|
|
|
),
|
|
|
("RUST_BACKTRACE", "1".to_string()),
|
|
|
(
|
|
|
- dioxus_cli_config::DEVSERVER_RAW_ADDR_ENV,
|
|
|
- devserver_ip.to_string(),
|
|
|
+ dioxus_cli_config::DEVSERVER_IP_ENV,
|
|
|
+ devserver_ip.ip().to_string(),
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ dioxus_cli_config::DEVSERVER_PORT_ENV,
|
|
|
+ devserver_ip.port().to_string(),
|
|
|
),
|
|
|
// unset the cargo dirs in the event we're running `dx` locally
|
|
|
// since the child process will inherit the env vars, we don't want to confuse the downstream process
|
|
@@ -145,7 +149,7 @@ impl AppHandle {
|
|
|
|
|
|
// https://developer.android.com/studio/run/emulator-commandline
|
|
|
Platform::Android => {
|
|
|
- self.open_android_sim(envs).await;
|
|
|
+ self.open_android_sim(devserver_ip, envs).await;
|
|
|
None
|
|
|
}
|
|
|
|
|
@@ -697,13 +701,30 @@ We checked the folder: {}
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
- async fn open_android_sim(&self, envs: Vec<(&'static str, String)>) {
|
|
|
+ async fn open_android_sim(
|
|
|
+ &self,
|
|
|
+ devserver_socket: SocketAddr,
|
|
|
+ envs: Vec<(&'static str, String)>,
|
|
|
+ ) {
|
|
|
let apk_path = self.app.apk_path();
|
|
|
let session_cache = self.app.build.krate.session_cache_dir();
|
|
|
let full_mobile_app_name = self.app.build.krate.full_mobile_app_name();
|
|
|
|
|
|
// Start backgrounded since .open() is called while in the arm of the top-level match
|
|
|
tokio::task::spawn(async move {
|
|
|
+ let port = devserver_socket.port();
|
|
|
+ if let Err(e) = Command::new("adb")
|
|
|
+ .arg("reverse")
|
|
|
+ .arg(format!("tcp:{}", port))
|
|
|
+ .arg(format!("tcp:{}", port))
|
|
|
+ .stderr(Stdio::piped())
|
|
|
+ .stdout(Stdio::piped())
|
|
|
+ .output()
|
|
|
+ .await
|
|
|
+ {
|
|
|
+ tracing::error!("failed to forward port {port}: {e}");
|
|
|
+ }
|
|
|
+
|
|
|
// Install
|
|
|
// adb install -r app-debug.apk
|
|
|
if let Err(e) = Command::new(DioxusCrate::android_adb())
|