Nativescript-cli: Critical: Cannot Update Android App

Created on 29 Dec 2017  路  5Comments  路  Source: NativeScript/nativescript-cli

_From @vbresults on December 28, 2017 7:26_

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yes

Tell us about the problem

I cannot sync my Android app. It seems to be loading the js not from the apk but from somewhere else it was cached weeks ago, and I can't clear this cache.

I've tried deleting the app cache in the android settings page, deleting the gradle cache, reinstalling the android platform, and NOTHING has worked. Where is this cache..?

It seems to be bound to com.example.mypackagename, the only solution right now is to use a different package name which is problematic.

The only thing I imagine could have triggered this is using the debug command recently, I have not been able to sync the source code to the Android app since.

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.3.0
  • Cross-platform modules: 3.3.0

_Copied from original issue: NativeScript/NativeScript#5214_

question android

Most helpful comment

@vbresults we recognize that this is a problem with certain devices (Samsungs, mostly), and is even more pronounced on devices of API 23+ where file permissions have become more strict.

The mechanism used is such that the changed files are sent to the device cache (the tmp dir), and at startup, the Android Runtime reads and copies the cached files in place of its own current files, then proceeds to delete the tmp directory. However that operation can fail on more restrictive Android distributions, such as those of Samsung S series.

As a workaround, if you see the problem occurring again while developing, deleting the data/local/tmp/<package.name> should be sufficient to get you back up and running. Releasing apps should not be a concern, as release apps disable the livesync android runtime mechanism.

As a fix - we could use a socket server on the device whose only purpose will be to serve the changed files to the application, and that would hopefully remove all errors which you are now experiencing.

All 5 comments

@vbresults uninstall the application from the device/emulator you are testing on and also remove platforms folder before rebuilding and redeploying the application with tns run android.

I would suggest migrating to the latest NativeScript 3.4.x (if using WebPack migration guide here)

_From @vbresults on December 28, 2017 11:8_

Found them... the caches are here:

/data/local/tmp/com.example.mypackagename/fullsync/main.js
/data/user/<uid>/com.example.mypackagename/

This appears to be some sort of bug with livesync that 1. leaves that directory behind after a reinstall and 2. causes it to be unaffected by tns build/run --clean.

@vbresults we recognize that this is a problem with certain devices (Samsungs, mostly), and is even more pronounced on devices of API 23+ where file permissions have become more strict.

The mechanism used is such that the changed files are sent to the device cache (the tmp dir), and at startup, the Android Runtime reads and copies the cached files in place of its own current files, then proceeds to delete the tmp directory. However that operation can fail on more restrictive Android distributions, such as those of Samsung S series.

As a workaround, if you see the problem occurring again while developing, deleting the data/local/tmp/<package.name> should be sufficient to get you back up and running. Releasing apps should not be a concern, as release apps disable the livesync android runtime mechanism.

As a fix - we could use a socket server on the device whose only purpose will be to serve the changed files to the application, and that would hopefully remove all errors which you are now experiencing.

Could also be related to this: NativeScript: Android application upgrade issues http://fluentreports.com/blog/?p=516#comment-32155

@Closing as this [particular issue is no longer reproducible on my side.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

charsleysa picture charsleysa  路  3Comments

PeterStaev picture PeterStaev  路  3Comments

NickIliev picture NickIliev  路  3Comments

donker picture donker  路  3Comments

Fatme picture Fatme  路  3Comments