`tns livesync android` not updating application consistently
I have seen other closed issues reporting similar issues; however, I appear to still be having an issue with tns livesync android. Whenever I run this command it sometimes updates the application and sometimes doesn't. I have run tns livesync android --emulator --watch and had the application refresh with the newly updated code as expected; however, it will randomly stop updating. I will Ctrl-C then re-run tns livesync android --emulator --watch and it won't pick up any changes. I receive no errors, and the application refreshes - just without any changes.
The only fix currently seems to be restarting my computer. I am able to get the expected functionality after this. Help is appreciated, thank you.
I know several people having this issue and is stopping us from developing with smooth and ease applications in nativescript.
Please someone help us! I love nativescript but I cant run "tns livesync" everytime I make a change in some ts/js file.
I am going to have to take a look at my log and post it here. @Bohmaster you are right man. NatvieScript is amazing and has so much potential. The Livesync issue is the main problem that stands out. I just don't know why it works perfectly on the Mac lol. I am coming from developing apps on Cordova/Ionic. The only good thing about working with the WebView was you could see everything as you were developing in the browser. Much different scenario here of course as we are not dealing with a WebView thanks God!! I think NativeScript would be 100% perfect if the Livesync issue was completed, and just for the sake of faster development maybe a front-end compatible UI framework. When I have the time I might try to put one together. The Telerik UI for {N} are just controls really and that doesn't count! haha.
@jwuliger Of course! It's a shame... I would love to contribute and develop intensively but this is bringing me down. I've tried both on Ubuntu and Windows systems and have had the same exact problem (EISDIR).
I'm using this repo as a seed: https://github.com/NathanWalker/angular2-seed-advanced. It's great and includes some cool libraries (ng/rx) and features.
@m-abs
@jwuliger Do you have the same output error (EISDIR)?
I have the same problem with the basic scaffold application (TAP button demo with JavaScript, not Angular 2). I am using nativescript 2.1.1, android sdk 25.1.7, platform sdk 23, build tools 23.0.3 android api 23 (Android 6) with Intel x86 Atom_64 System Image as emulator. The system is Ubuntu Gnome 16.04 I change the main-page.xml (f.e. change button text) and it is applied immediately (no application restart, which is great) on the first change. All changes after that are not picked up until I uninstall the application. JavaScript changes are picked up, but the application restarts (I understand this is the current state of affairs).
Output shows no problem
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.8/userguide/gradle_daemon.html
Project successfully built
Project successfully prepared
Transferring project files...
Successfully transferred main-page.xml.
Applying changes...
Successfully synced application org.nativescript.VotingApp on device emulator-5554.
Project successfully prepared
Transferring project files...
Successfully transferred main-page.xml.
Applying changes...
Successfully synced application org.nativescript.VotingApp on device emulator-5554.
I noticed that when I restart the app in the emulator manually (without uninstall/reinstall) the changes are visible as well. So it may be just a missing restart? (But since it works on the first change, perhaps it would be possible to have that always without a restart, that would be nice ;) )
Hey @everflux @Bohmaster @jwuliger @pess0a,
As far as I understand the issue is only related to XML files. Is that true? Can you try to change something in the CSS to see if subsequent changes will work?
Do you change something in the main screen of the app or you have navigation and you are changing some of the inner pages?
I had the same issue with CSS changes, even when the app is relaunched by the nts cli. JS changes seem to be applied consistently.
Hey @everflux,
Can you post the exact steps (from project creation) and/or send us your project to try it locally?
I used the tns cli to create the app, when zipping it, it was about 70MB so I removed node_modules and platforms. Creation was done using
tns create VotingApp
tns platform add android
tnx livesync android --watch
I've just tried your app however everything worked as expected on my end. All changes are synced and the app is refreshed not matter if this is first or subsequent change. Changes in JavaScript files are synced with app restart and changes in XML/CSS with page reload.
Here is my environment: Windows 10 Pro 64-bit Node 4.4.5 Android 6 API 23 x86-64bit
Can you share the full app with platforms and node_modules as well?
PS: You do not need to call tns platform add android (second step). Livesync command will handle everything automatically.
Hi, I am using Windows 7 64-bit, TNS version 2.1.1, Node 4.4.6 (always use Recommended for Most Users), Android 6 API 23x86-64bit and not facing any issue with standard livesync command except the emulation is very very slow. So, I switched to Genymotion and I used the following one simple command to emulate on Geny and it worked smoothly: tns livesync android --geny "my device name" --watch
Hey @yadinesh,
You can use hardware accelerated emulators (HAXM) instead Genymotion.
@everflux Can you try npm cache clean and try again?
I am using Linux (Ubuntu), and not latest node, perhaps this makes a difference. I will try the cache clean. (Attaching he sample with platform/node_modules is not possible on github due to file size restriction.)
After cache clean / npm install I get the same behaviour, this time change in the CSS, which is correctly detected by the tns cli, but the sync is not applied
BUILD SUCCESSFUL
Total time: 42.361 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.8/userguide/gradle_daemon.html
Project successfully built
Project successfully prepared
Transferring project files...
Successfully transferred app.css.
Applying changes...
Successfully synced application org.nativescript.VotingApp on device emulator-5554.
Can you try Node 4.4.7 (latest recommended) if possible?
@enchev: I am already using Intel HAXM but seems that Genymotion is better. May be, I don't have a highly compatible configuration in my system with HAXM. Thanks anyways !
Hello @enchev I will give you as much detailed information as possible for my situation.
I have 2 separate development workstations at my desk. One is a PC and the other a Mac.
Both workstations have the latest versions of everything you can name or think of. I use the AVD HAXM Android emulators on both the Mac & PC. I have tried the stand-alone SDK way and with Android Studio.
On my Mac I do not have a single problem. Changes made to CSS/XML or HTML (NG) files change and reload both the emulator when I am using it as well as on the actual devices I am using.
The problem is with the PC. Only TS/JS files trigger a Livesync reload. This is the same for the emulator and device. I have tried with the “—watch” command and without.
I have also tried with Node LTS and Node 6+
PC Dev Environment:
- Windows 10 Enterprise
- Node v6.3.0 (Same problem with v4.4.7 LTS)
- NPM v3.10.6
- Latest version of the TNS CLI. In fact, I have even tried the nightly builds. So for the very moment I am using v2.2.0-non-ci (Same problem with official release though).
- TNS Android 2.1.0
Projects I have tried:
- Hello World Typescript
- Hello World Angular 2
- The Master branch of the Groceries app
- The project I am working on (My company's prototype app) which is based off the latest Angular 2 starter using RC3.
In short I am able to take the same Android project that Livesync does not work with on my PC, and run it on my Mac and it works perfectly.
The only thing Livesync cannot seem to do is sync both iOS and Android at the same time. I have read in other issues that this is already known.
I would like to help in any way I can. Is there a way for me to send you any type of log file that would help you see what’s going on? I can also do a screen recording of the issue if that would help. Please let me know what I can do.
Thanks for your help!
Hey folks,
We were able to reproduce this problem on one of our machines and after reinstalling the Android SDK the issue went away. Unfortunately we were unable to find the real source of the problem however we believe that this is related to broken device communication.
Please try the same at your end and let us know!
Awesome, thank you for your efforts. I am currently using this command to install the SDK, should I use the latest/different version of build tools instead?
wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
tar -zxf android-sdk_r24.4.1-linux.tgz
cd android-sdk-linux
./tools/android update sdk --no-ui --all --filter tools,platform-tools,android-23,build-tools-23.0.3,sys-img-x86_64-android-23,extra-android-m2repository,extra-google-m2repository,extra-android-support
I know im writing into a closed issue, but for everyone experiencing this problem on TNS <= 2.2.0 fix is simple. Edit your installation of nativescript android-livesync-service.js mine was in the
C:\Users\%yourname%\AppData\Roaming\npm\node_modules\nativescript\lib\services\livesync\android-livesync-service.js
Delete lines:
AndroidLiveSyncService.prototype.sendPageReloadMessage = function () {
var future = new Future();
var socket = new net.Socket();
socket.connect(AndroidLiveSyncService.BACKEND_PORT, '127.0.0.1', function () {
try {
socket.write(new Buffer([0, 0, 0, 1, 1]));
future.return();
}
catch (e) {
future.throw(e);
}
finally {
socket.destroy();
}
});
return future;
};
Instead insert:
AndroidLiveSyncService.prototype.sendPageReloadMessage = function () {
var future = new Future();
var socket = new net.Socket();
socket.connect(AndroidLiveSyncService.BACKEND_PORT, '127.0.0.1', function () {
socket.write(new Buffer([0, 0, 0, 1, 1]));
});
socket.on("data", function(data) {
socket.destroy();
future.return();
});
return future;
};
And livereload works now
@archonik This works now but not for css files. Can you check that? Both xml and .ts/js files reflects as spected. To see css files reflected I need to kill the process and run it manually again for every change.
@archonik Awesome stuff! I can confirm with @Bohmaster CSS files still do not work. I get this in the console: Error: undefined:1:8: missing '{' even though I have valid CSS.
It is also very very slow. Better than not working though!! Nice work!