_From @ryc16 on October 18, 2016 9:28_
I recently started to build a debug apk for easy of deploying various devices for testing (which also similar production deployment) but I encountered very strange behavior. Apk got deployed but content sometimes show updated and sometimes not. Also same apk deploy to 2 devices but one shows correctly but another devices shown incorrectly. This could be easy to tell looking at UI already. The problem happen randomly so very painful. I wish more people try this way and see if more people got the same problem.
Steps:
From app info, both devices got the same, in term of content, they look different see the attachment for 2 devices.
Device1: content not updated look like old UI.
hw.zip
Device2: content did updated show correctly
note2.zip
On device 1, Also try clean cache, clean data on the device, uninstall package from device package manager, then install apk from my share place. Still had same problem - correct app version but incorrect content.
Any idea? How can I further troubleshoot? How could I know what content I am running on?
I am a bit worry what happen if this is on production environment, Would user will face this problem? If so, user wouldn't know about it. So this is very critical issue.
Only tried on Android not IOS
>tns info
All NativeScript components versions information
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ Component โ Current version โ Latest version โ Information โ
โ nativescript โ 2.3.0 โ 2.3.0 โ Up to date โ
โ tns-core-modules โ 2.3.0 โ 2.3.0 โ Up to date โ
โ tns-android โ 2.3.0 โ 2.3.0 โ Up to date โ
โ tns-ios โ โ 2.3.0 โ Not installed โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
_Copied from original issue: NativeScript/NativeScript#2918_
_From @ryc16 on October 18, 2016 11:5_
In order to get the content up to date, I have to plug my device to my computer and use tns command.
tns livesync android --watch
Afterwards, everything works as expect.
Again, I am worry what would be happend if app is in production and install from ie google play store. Would this happen?
Hi @ryc16,
I couldn't reproduce your problem when I repeated the steps you provided. I tried building the default application and installing it by hand on different emulator api levels: 17, 19, 21, 24. The resulting UI is the same. If you want us to help you, can you provide a small repo causing the problem and be more specific with the api versions you tried running the application on?
@Plamen5kov, this doesn't happen all the time. I just wonder how does the android deployment works. Where does the content running at? For example, running at /data/data/
@ryc16 when adb -r install <apk_name>-debug.apk is called, the application is copied on the device
/data/app/<app_name>.apk and/data/app/<app_name>-1/base.apkand then unpacked inside the folder you mentioned
/data/data/<full_app_name>/
When the app is uninstalled all these directories are deleted, so I can think of no way for the same app to have different behavior. I can suggest using the -r option on the adb command that will remove the previous application with the same name before installing the new one, or uninstalling manually before installation.
Adb command is:
adb install -r <apk_name>.apk
@Plamen5kov, I could try when it happen again (I didn't uninstall from device app manager which I think the same so not sure if adb -r helps). Is adb -r is the regular deployment process or handle by tns android cli? If your suggestion is just for troubleshooting, then it is ok otherwise this wouldn't be production solution. So there is no cache mechanism of running content, right? What about the javascript layer? Hope other people could replicate this problem.
Is adb -r is the regular deployment process or handle by tns android cli?
@ryc16, yes the CLI uses -r as the default command when installing the application as you can see here.
So there is no cache mechanism of running content, right?
I can't tell you if android has a cache mechanism, I haven't looked into it.
If your suggestion is just for troubleshooting, then it is ok otherwise this wouldn't be production solution.
I can't reproduce the issues at hand, so it's a suggestion to help you isolate the problem. If we manage to do that, we can figure it out.
I've seen this issue too... very strange!
I updated an XML file to fix a spelling issue, tested it on a real Nexus 7 device worked fine. Uploaded the debug apk to a server and downloaded it to a real Motorola G and the old UI was still there!
Now more people are able to catch this strange problem. This kind of problem is very scary if it is on production. We don't know if user really running/showing the latest content.
Hi @ryc16,
I agree with you, but you have to understand, if we can't reproduce your problem, we can't fix it. I would be grateful if you find a scenario, where this bug can be reproduced, so we can take it on.
Hi @Plamen5kov, understood. it is not consistent to me so not sure how to let you reproduce the problem.
@therevills, is it consistent to you? would you have anything for @Plamen5kov .
@ryc16 did you mange to isolate the issue, or find a way for us to reproduce it?
I'm closing this issue, because there's no response, but feel free to reopen it again, if you find a way to reproduce it.
Hey, I am also facing the same issue. It's very frustrating. In my scenario, I added few images on app resources and when I tried to run the app. It shows me the previous content.
I am using NativeSctipt 2.5
I got the issue. The issue was I changed the NativeSctipt id but had not changed in app.gradle therefore it was giving me this kind issue. For more information you can refer https://github.com/NativeScript/nativescript-cli/issues/2092
Hi @mayureshjadhav,
Could you provide steps to reproduce the problem. Keep in mind that when using livesync all changes made are passed directly to the device, and when all fixes using livesync are done a normal build needs to be made so a new .apk is generated: tns build android/ios.
Will close this issue because there's no steps to reproduce and lack of interest. Feel free to reopen if someone can provide steps to reproduce.
@Plamen5kov please re-open... Believe it or not; I just saw this issue. Wasted about 2 hours of my time. ;-(
However, I know what happened, not 100% if it is easily duplicatable, I didn't retry -- but I know how I fixed it and what caused it...
tns build android). /data/local/tmp thinking it apparently needed to "update"... Of course the version in that folder was outdated as I had two new fixes... Blew my mind everytime I started the app and it did the old behavior. Spend a while debugging again until I realized my source didn't have the two fixes. Ugh!!!
Open the debugger and it showed the old JS, open up the APK and it had the new files. Finally looked on the raw device, and it had the old files...
Once I deleted the /data/local/tmp directory for my app; then the install worked great...
So somehow the LiveSync on startup was getting confused and thought the /data/local/tmp was a later version even though a bit of time went by while I was building new version (no more livesync'g as I wanted a test build to give my clients)...
@NathanaelA thanks for describing the process in details.
It just came to my attention that we face the problem internally too. I can finally confirm that this is indeed an issue with temp directory not being erased on certain devices, despite permissions being granted.
I would also like to add that the bug does not affect packages built in release, so publishing and updating applications should be safe.
Addressed with changes in PR https://github.com/NativeScript/android-runtime/pull/743 as well as some modifications inside the CLI version 3.0.0
@Pip3r4o how do we go about getting this update?
Since I couldn't quite figure it out, this was a temporary workaround for me.
Based off of the comments, I was able to delete the files in /data/local/tmp/ using adb and now my apk that I installed is actually using the files from the apk.
to get the directory name, you can find it by running this
adb shell ls /data/local/tmp/
Then, I did
adb shell rm -rf /data/local/tmp/org.nativescript.MYAPPNAME
@cjdreiss 3.0.0 will be officially released next week. Using the 3.0 CLI and installing the 3.0 android runtime in your projects (even if you still use 2.5 modules) should prevent your files from going stale.
+1 Reported via t.1119637 with tns-android 3.2.0
@NickIliev the changes released earlier this year unfortunately do not fix the problem occurring on Samsung devices.
I can confirm this still happens with 3.3.1
to reproduce:
tns run androidtns build android and then adb install path/to/appName-debug.apk to the same device/emulator that the livesync was hooked up totns deploy android to the same device/emulator that the livesync was hooked up toThis problem doesn't seem to affect release builds (tns build android --release) or clean deploy (tns deploy android --clean)
what is the solution plz
Most helpful comment
I can confirm this still happens with 3.3.1
to reproduce:
tns run androidtns build androidand thenadb install path/to/appName-debug.apkto the same device/emulator that the livesync was hooked up totns deploy androidto the same device/emulator that the livesync was hooked up toThis problem doesn't seem to affect release builds (
tns build android --release) or clean deploy (tns deploy android --clean)