简体   繁体   中英

How can I restore Nativescript application code from android device?

When I create an APK while developing a Nativescript application, Nativescript stores all the application code in the generated APK file, and that helps me a lot in case something bad happened to the code[The code was deleted, Didn't commit changes I was working on for a long time,...]. When something bad happens to the code, I usually generate an APK from my android device using any APK Extractor tool and decompile it with JADX to obtain my original code and save my day.

Nativescript doesn't generate NEW APKs when I make changes to layout or js files[even though changes are applied on the android device]. Nativescript generates new APKs only when I build the project. and that doesn't help a lot when I need to restore my code after a lot of changes on it.

We're working on a nativescript application. We've been making changes on the application for about two days without generating new APK nor committing changes to git. The files where suddenly removed from pc and we don't know why.

We extracted an APK from the latest working version on the test android device, decompiled it and retrieved the code but the changes of the last two days weren't there.

Is there a way to restore the code from a Nativescript application installed on android devices? By restoring the code I mean even restore all the changes on the code after building the application.

Where/How does nativescript store the instant changes on the code for my application on the android device?

You can view your code by accessing the application data from adb.

connect to your application from adb

adb shell run-as org.nativescript.myapplication

and you can find your files in this directory

/data/data/org.nativescript.myapplication/files/app

It's not wise to depend on your APK for retaining your source code, you should probably use a Version Control System like Git, may be services like Github / BitBucket / GitLab etc., to maintain your source code.

While using a Version Control System, you should commit your changes regularly. That's the whole purpose here, even if you are not sure about your changes you can still use your own branch and keep the changes committed and merge to main branch only when it's fully ready.

I guess you are not using the --bundle option while you run / build the app which is recommended to keep your application lightweight at same time provides a minimal obfuscation using Uglify. With next major release of NativeScript this --bundle option will be marked as default, so you will no longer be able to extract your exact source code at all.

Also think if someone wants to hack your app while you haven't followed any obfuscation, it's easy to clone your work Or break the functionality as they wish. Learn more about securing your source code here .

Still regarding where the live changes are being stored, I think it will be within application data directory on Android.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM