nativescript-cli: `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.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 57 (10 by maintainers)

Most upvoted comments

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.

@brandon-thimmesch is there any chance that you have app.gradle in your app/App_Resources/Android directory and there’s your id in it? I had similar issue when I’ve added my app identifier in the app.gradle and changed it later in my package.json only.

Okay - It seems that uninstalling the app from the device, then closing and reopening the command line works as well. Restarting the computer isn’t necessary, but I’m still having the livesync lose the ability to update the application with current code, even after Ctrl-C and re-running the command. I’ve run tns doctor, and everything is installed and running correctly.

Thanks again for the help.

I had the same problem, unfortunately with Nativescript version 2.3.0… I created a blank app with ng create and it froze the content of the component (the Tap-button and counter).

I uninstalled the app on the emulator and it works fine again, changes made in the HTML files are being updated again.

@m-abs thanks man, its hard trying to prove that NS can hold up to r-n when the most needed thing as livesync does not work properly, glad i helped 😃.

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

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.

@jwuliger try to delete the platform folder using the command for example, if you want to delete the Android folder you need to:

tns platform remove android

then run:

tns platform add android
tns build android

those commands will do the job, after that you can run livesync. The new version of nativescript cli will inform if he didn’t refresh something or not in those cases you need to build first and then run livesync