nativescript-cli icon indicating copy to clipboard operation
nativescript-cli copied to clipboard

`tns livesync android` not updating application consistently

Open brandon-thimmesch opened this issue 10 years ago • 57 comments

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.

brandon-thimmesch avatar Jun 22 '16 18:06 brandon-thimmesch

Hey @brandon-thimmesch,

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

enchev avatar Jun 23 '16 06:06 enchev

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

brandon-thimmesch avatar Jun 23 '16 14:06 brandon-thimmesch

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

enchev avatar Jun 24 '16 13:06 enchev

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.

brandon-thimmesch avatar Jun 24 '16 20:06 brandon-thimmesch

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!

jwuliger avatar Jun 27 '16 14:06 jwuliger

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 avatar Jun 28 '16 15:06 vchimev

@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

brandon-thimmesch avatar Jun 28 '16 16:06 brandon-thimmesch

Hey @brandon-thimmesch,

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

enchev avatar Jun 30 '16 11:06 enchev

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!

jwuliger avatar Jun 30 '16 12:06 jwuliger

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.

brandon-thimmesch avatar Jun 30 '16 15:06 brandon-thimmesch

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

jwuliger avatar Jun 30 '16 15:06 jwuliger

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

rosen-vladimirov avatar Jun 30 '16 15:06 rosen-vladimirov

@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 avatar Jul 01 '16 20:07 Alexisvt

@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 avatar Jul 02 '16 01:07 jwuliger

@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

Alexisvt avatar Jul 03 '16 02:07 Alexisvt

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!

jwuliger avatar Jul 03 '16 05:07 jwuliger

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.

Bohmaster avatar Jul 03 '16 06:07 Bohmaster

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.

pess0a avatar Jul 03 '16 16:07 pess0a

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

jwuliger avatar Jul 03 '16 21:07 jwuliger

@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

Bohmaster avatar Jul 03 '16 21:07 Bohmaster