Skip to content

tns livesync android not updating application consistently #1872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brandon-thimmesch opened this issue Jun 22, 2016 · 57 comments
Closed

tns livesync android not updating application consistently #1872

brandon-thimmesch opened this issue Jun 22, 2016 · 57 comments
Assignees
Labels
Milestone

Comments

@brandon-thimmesch
Copy link

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.

@enchev
Copy link
Contributor

enchev commented Jun 23, 2016

Hey @brandon-thimmesch,

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

@brandon-thimmesch
Copy link
Author

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

@enchev
Copy link
Contributor

enchev commented Jun 24, 2016

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

@brandon-thimmesch
Copy link
Author

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.

@jwuliger
Copy link

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!

@vchimev
Copy link

vchimev commented Jun 28, 2016

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?

@brandon-thimmesch
Copy link
Author

@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

@enchev
Copy link
Contributor

enchev commented Jun 30, 2016

Hey @brandon-thimmesch,

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

@jwuliger
Copy link

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!

@brandon-thimmesch
Copy link
Author

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.

@jwuliger
Copy link

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

@rosen-vladimirov
Copy link
Contributor

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

@Alexisvt
Copy link

Alexisvt commented Jul 1, 2016

@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

@jwuliger
Copy link

jwuliger commented Jul 2, 2016

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

@Alexisvt
Copy link

Alexisvt commented Jul 3, 2016

@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

@jwuliger
Copy link

jwuliger commented Jul 3, 2016

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!

@Bohmaster
Copy link

Bohmaster commented Jul 3, 2016

Could be related to this? #1810 (comment)

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

@pess0a
Copy link

pess0a commented Jul 3, 2016

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.

@jwuliger
Copy link

jwuliger commented Jul 3, 2016

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

@Bohmaster
Copy link

Bohmaster commented Jul 3, 2016

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

#1810 (comment)

@Bohmaster
Copy link

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.

@jwuliger
Copy link

jwuliger commented Jul 3, 2016

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.

@Bohmaster
Copy link

Bohmaster commented Jul 3, 2016

@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)?

@everflux
Copy link

everflux commented Jul 10, 2016

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 ;) )

@tzraikov tzraikov self-assigned this Jul 11, 2016
@enchev
Copy link
Contributor

enchev commented Jul 12, 2016

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?

@everflux
Copy link

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.

@enchev
Copy link
Contributor

enchev commented Jul 12, 2016

Hey @everflux,

Can you post the exact steps (from project creation) and/or send us your project to try it locally?

@everflux
Copy link

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

@archonik
Copy link

archonik commented Jul 22, 2016

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

@Bohmaster
Copy link

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

@jwuliger
Copy link

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

@Kobzol
Copy link

Kobzol commented Jul 22, 2016

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.

@archonik
Copy link

archonik commented Jul 22, 2016

@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

@Bohmaster
Copy link

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.

@m-abs
Copy link

m-abs commented Jul 22, 2016

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

@archonik
Copy link

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

@iamnotagit
Copy link

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!

@m-abs
Copy link

m-abs commented Jul 25, 2016

@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

@jwuliger
Copy link

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

@iamnotagit
Copy link

iamnotagit commented Jul 26, 2016

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

@m-abs
Copy link

m-abs commented Jul 26, 2016

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

@iamnotagit
Copy link

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

@iamnotagit
Copy link

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

@jwuliger
Copy link

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

@gazlu
Copy link

gazlu commented Nov 3, 2016

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

We need to provide device ID/Index

@Taremeh
Copy link

Taremeh commented Nov 11, 2016

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.

@zakdances
Copy link

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?

@valentinstoychev
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests