|
@@ -163,7 +163,7 @@ impl AppHandle {
|
|
|
/// This will return the bundled name of the asset such that we can send it to the clients letting
|
|
|
/// them know what to reload. It's not super important that this is robust since most clients will
|
|
|
/// kick all stylsheets without necessarily checking the name.
|
|
|
- pub(crate) fn hotreload_bundled_asset(&self, changed_file: &PathBuf) -> Option<PathBuf> {
|
|
|
+ pub(crate) async fn hotreload_bundled_asset(&self, changed_file: &PathBuf) -> Option<PathBuf> {
|
|
|
let mut bundled_name = None;
|
|
|
|
|
|
// Use the build dir if there's no runtime asset dir as the override. For the case of ios apps,
|
|
@@ -196,6 +196,25 @@ impl AppHandle {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // If the emulator is android, we need to copy the asset to the device with `adb push asset /data/local/tmp/dx/assets/filename.ext`
|
|
|
+ if self.app.build.build.platform() == Platform::Android {
|
|
|
+ if let Some(bundled_name) = bundled_name.as_ref() {
|
|
|
+ let target = format!("/data/local/tmp/dx/{}", bundled_name.display());
|
|
|
+ tracing::debug!("Pushing asset to device: {target}");
|
|
|
+ let res = tokio::process::Command::new("adb")
|
|
|
+ .arg("push")
|
|
|
+ .arg(changed_file)
|
|
|
+ .arg(target)
|
|
|
+ .output()
|
|
|
+ .await
|
|
|
+ .context("Failed to push asset to device");
|
|
|
+
|
|
|
+ if let Err(e) = res {
|
|
|
+ tracing::debug!("Failed to push asset to device: {e}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// Now we can return the bundled asset name to send to the hotreload engine
|
|
|
bundled_name
|
|
|
}
|