Nativescript-cli: `tns livesync android` not updating application consistently

Created on 22 Jun 2016  ·  57Comments  ·  Source: NativeScript/nativescript-cli

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.

question

Most helpful comment

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.

All 57 comments

Hey @brandon-thimmesch,

Can you post more info about {N} CLI version?

Oh - my bad, forgot to include that. I am working with v 2.0.1

Hey @dtopuzov @vchimev @SvetoslavTsenov can you confirm this?

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.

Hello I am having the same issue. I am working on an Android app on Windows 10 with v2.0.1 using TypeScript.

With the Watch flag enabled, it does close and restart the app on the AVD emulator I am using. The changes I make just do not show up.

The process of uninstalling the app from the emulator, closing the cmd and re-running tns livesync android --emulator --watch works for a short period of time.

Am I doing anything wrong? Thanks so much for any help!

Thanks for the report, @brandon-thimmesch and @jwuliger!

Could you please elaborate more on:

  • what devices: model, API level
  • what emulators: android SDK emulator, Genymotion, others

do you experience this problem?
Also:

  • do you experience problems to sync only js files?
  • do xml and css files sync successfully?

After what period of time approximately the livesync command stops to show up your changes?

Currently, we work on the release of NativeScript 2.1.0 and it is expected to be published later this week. Could you please give it a try when it is official as we we have not manage to reproduce such an issue yet?

@vchimev Absolutely, it seems to occur more often when using an emulator. Here are my details:

Devices:

Type: Physical Device (Samsung S5)
Android Version: 5.0.1
API level: 21

Type: Android SDK Emulator (Android N Nexus 6)
CPU/ABI: Intel Atom (x86)
RAM: 768
VM Heap: 32
SD Card size: 200M
API level: 24

Sync only appears to occur when js files are saved. No changes are applied for xml and css files when saved.

TL;DR : The emulator seems to be experiencing the problems more often than the physical device.

The cessation of livesync functionality appears to be occurring fairly randomly. As a general estimation I would say that for the emulator this was occurring about once an hour. For the physical device it happened far less often, and have not in fact had a major issue in the past few days; however, I have been reading documentation for a project and haven't been developing as much in the past few days.

I will update when {N} 2.1.0 is released, and work with the emulator to see if the issue occurs again

Hey @brandon-thimmesch,

We've just released our 2.1.0 release. Please try it and let us know if you still have problems!

Sorry I missed the notification on this! 2.1.0 is exciting! I will install now to see if that changes anything. Just a quick note here also. When developing on my Apple, livesync had no issues at all. OK going to try this new version out!

Hey @enchev

I have updated to 2.1.0 and appear to still be having the issue with the application not updating.
I am still needing to delete the app from my phone and reinstall to see the changes made to the code.

Hello, I have also updated everything but now I am having trouble getting my app to run/build at all.

@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.

@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

@Alexisvt Hello, thanks for the response! I found that the reason I was not able to build my app was a plugin that needed to be updated. My app now run and builds fine. As far as livesync is concerned, making any changes to an xml file or a css file does not update the changes in the AVD emulator. This is using the command: tns livesync --emulator --watch The problem is no different on the actual device. You are not able to see the changes made unless you stop the process in the CMD console and rebuild the app. When I do make these changes the CMD console reports that the files I made were changed. Here is an example:

Executing before-prepare hook from C:\Migration\RequestIt.Mobile\hooks\before-prepare\nativescript-dev-typescript.js Project successfully prepared Transferring project files... Successfully transferred about.xml. Applying changes... Successfully synced application com.requestitinc.requestit on device 05157df55a9de805.

However the changes like I said are never made. Please let me know if there is anything I can do or any other information I can provide to help find a solution. It is very difficult to build an app's UI when you are not able to see the changes. Thanks for your help!

@jwuliger There are indeed some stuff that can't be update it when you use livesync the new version of nativescript cli (v 2.1) add a warning telling you what changes can not be update it. The workaround is to stop livesync then call tns build android/ios then call livesync to see the changes. If you want to read more about it please follow this link

I agree with you that there are items that cannot be updated. I am speaking about layout xml and CSS files. Using CLI 2.1 on my iMac the very same files that do not change on my PC/Android do change effortlessly and without problem in any iOS Sim and devices. The same file in the same app on the same CLI version behaves differently. Even with the latest hello world starter. One thing I should try is running the android version on the Mac. I know other people are having this problem as well. I just want to help in any way I can. Thanks!

Could be related to this? https://github.com/NativeScript/nativescript-cli/issues/1810#issuecomment-230140384

I've tried on Windows and Ubuntu and have had the same result.

Same problem here. just sync .js files. xml and css logs said that was updated but it doesn't. need to close app and open it again. don't need to build again.

@Bohmaster that issues looks very similar. In my case I am just using Typescript and not NG2.

@jwuliger

Here I have the --log trace output. I think here must be the error

log.txt

This is an excerpt of what I suspect there is something wrong:

**Project successfully prepared
AfterHookName for command prepare is after-prepare**

spawn: C:\Users\voidhmaster\AppData\Local\Android\android-sdk\platform-tools\adb "-s" "192.168.155.101:5555" "shell" "ls" "-l" "/data/local/tmp"
Result when throw error is false:
{ stdout: 'drwxrwxrwx root     root              2016-07-03 02:29 com.yourdomain.appname\r\r\n',
  stderr: '',
  exitCode: 0 }
spawn: C:\Users\voidhmaster\AppData\Local\Android\android-sdk\platform-tools\adb "-s" "192.168.155.101:5555" "shell" "rm" "-rf" "/data/local/tmp/com.yourdomain.appname/fullsync" "/data/local/tmp/com.yourdomain.appname/sync" "/data/local/tmp/com.yourdomain.appname/removedsync"
Result when throw error is false:
{ stdout: '', stderr: '', exitCode: 0 }

https://github.com/NativeScript/nativescript-cli/issues/1810#issuecomment-230140384

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

sample.zip

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!

A very similar CSS error also shows for me, even though I removed all CSS. It only shows if I use the Sass or Less preprocessors, there's no error with plain CSS.

@Bohmaster @jwuliger Im using just plain css not sass/less for my project so i cant even guess where the problem lies.

Im also using angular2

I've installed this and now it works. I don't know if it's related.

I'm using angular 2 and I've added "require('nativescript-liveedit)" inside mi main app.ts/js file.

@archonik Thank you very much, that seems to have solved the sync issue for me.
I just had to do a fullsync first (uninstall app and livesync) and now css, html, js are all synced as expected.

@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 :).

Hi @m-abs , can you explain what you mean by doing a full sync please? I would love to get this to work.

Do you mean to uninstall the android platform and nativescript, then reinstall them again (tns platform add android) and (npm install nativescript -g) ?

Many thanks!

@iamnotagit
By full sync I mean remove platforms folder and uninstall app from phone/emulator.
Don't run npm install nativescript -g you'll remove the fix from @archonik

If you feel like living on the edge - you can always use the nightly build. It has had the fix it for a little while now. npm install -g http://nativescript.rocks/master/nativescript-cli-master.tgz

Thank you for your guidance @m-abs @jwuliger!

@m-abs I removed (deleted) the 'platform' folder (though, won't this still get built/reproduced again, on save?). I am using the emulator, Genymotion. How would I uninstall the app? Have I correctly understood what it is you are saying?

@jwuliger I installed and had a go at the edge version. It works, in terms of updating CSS changes, though the results/appearance were not consistent between the stable and edge version unfotunately ('SIGN UP' button and font size). I guess that is the nature of 'edge'.

comparison

@iamnotagit
You uninstall the app just like you would uninstall any other app on an android device.
Open settings -> Apps -> find the in the list and tap on it -> tap "uninstall".

Thanks for the explanation @m-abs! I have managed to get this working!!

@jwuliger Thanks again for your suggestion of using the 'edge' version.

I don't believe now that it was because of the 'edge' release that I was getting different CSS results.
When using the stable version, I noticed that I would sometimes have this happen as well.

@iamnotagit Not a problem. I also have many inconsistencies. I am looking forward to version 2.2!! It looks like it is coming soon :)

This seems to work fine
tns livesync android --device 80de14e5 --watch

We need to provide device ID/Index

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.

I'm using the Android emulator livesync with tns 2.4.2.. Changes to CSS and HTML trigger a weird soft restart which causes some third party plugins to break. Changes to my TypeScript files, however, restart the app correctly with no problems.

Is there a way (in a hook file or elsewhere) to force CSS and HTML to do the same restart as TypeScript files?

@zakdances we are very interested to know the specifics of this. Which plugins break when CSS/HTML is changed?

Was this page helpful?
0 / 5 - 0 ratings