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
Unable to run existing android app after upgrading to 1.6.0 #1577
Comments
From @NathanaelA on February 17, 2016 17:1 Did you upgrade BOTH the core modules, and the runtime? |
From @Daxito on February 17, 2016 17:5 I followed these instructions: https://docs.nativescript.org/releases/upgrade-instructions npm install -g nativescript |
From @NathanaelA on February 17, 2016 17:6 Yep; those are the correct instructions. I'm currently in the process of upgrading one of mine. (Slow internet right now for some reason). I'll let you know how it goes... |
From @NathanaelA on February 17, 2016 17:13 Interesting, I have duplicated this issue on my own project. Investigating... |
From @Daxito on February 17, 2016 17:23 I see, thanks! |
From @NathanaelA on February 17, 2016 18:20 Are you loading / running any plugins inside the app.js? |
From @Daxito on February 17, 2016 18:45 Yes, under the node_modules I have lodash, moment, nativescript-drop-down, nativescript-sqlite, nativescript-telerik-ui, numeral, string. |
From @Daxito on February 17, 2016 18:48 oh wait, inside the app.js And directly under app.js: |
From @NathanaelA on February 17, 2016 18:51 Can you post your app.js file. Your comment above left me confused. 😀 |
From @Daxito on February 17, 2016 18:54 here it is: var application = require("application"); application.cssFile = "./app.css"; application.resources["dateConverter"] = converters.dateConverter; global.TOKEN_DATA_KEY = "authenticationToken"; // Initialize Everlive SDK global.COMPANY_CODE = null; application.onSuspend = function () { application.onResume = function () { application.onExit = function () { application.onLowMemory = function () { application.onUncaughtError = function (error) { application.start(); |
From @Daxito on February 17, 2016 18:56 Converters content is: var moment = require("moment"); var visibilityConverter = function (value) { //To View Converter var numberConverter = function (value, format) { var dateConverter = function (value, format) { var timeConverter = function (value, format) { var idToNameConverter = function (value, items, defaultText) { exports.visibilityConverter = visibilityConverter; |
From @Daxito on February 17, 2016 18:57 connection-monitor content is: var connectivity = require("connectivity"); module.exports = (function () {
})(); |
From @NathanaelA on February 17, 2016 19:6 Ok, I want you to try something. It will break your app later I'm sure; but lets see if it actually runs. If that doesn't work try commenting out: If that doesn't work, comment out both EverLive and Connection_Monitor . |
From @rosen-vladimirov on February 17, 2016 19:11 Guys, can you try removing these lines application.cssFile = "./app.css";
application.mainModule = "./views/login/login"; and replace the start method with this one: application.start({ moduleName: "./views/login/login" }); |
From @Daxito on February 17, 2016 19:13 Let me try all the recommendations right now. |
From @NathanaelA on February 17, 2016 19:26 @rosen-vladimirov In my specific case switching the cssFile/MainModule to the new way didn't help. In fact I did quite a few things to my project and finally narrowed it down to the actual context access. I would not be surprised if something in his app is doing the same thing. |
From @rosen-vladimirov on February 17, 2016 19:27 ok, I'll try to reproduce it on my side as well. Can you guide me for something specific. Why your app worked with 1.5.2 and not with 1.6.0 |
From @Daxito on February 17, 2016 19:30 OK, so this is the cause of the issue in my case, this is what gets called from the app.js when the module is "required", as you can see: var connectivity = require("connectivity"); |
From @Daxito on February 17, 2016 19:31 And this is a copy of my manifest, just in case:
|
From @rosen-vladimirov on February 17, 2016 19:32 This is the manifest from |
From @Daxito on February 17, 2016 19:34 Correct, this is the new default manifest generated, I just added: |
From @NathanaelA on February 17, 2016 19:36 @rosen-vladimirov Here is the key why it is crashing so you don't have to debug it...
See the utils.ad.getApplicationContext() -- the minute you get the Application context without the Application being started it crashed. In my code Either of these two lines will cause it to crash:
I have a routine that initializes a plugin; if the {N} application.context isn't yet set then it uses those two methods listed above to get the actual context. This has worked since v1.2 when I first wrote the code. |
From @rosen-vladimirov on February 17, 2016 19:41 Great work @NathanaelA , |
From @rosen-vladimirov on February 17, 2016 19:41 We'll have to check this with the runtime and modules teams. @slavchev , @hshristov any thoughts on this? |
From @Daxito on February 17, 2016 19:47 Yes @rosen-vladimirov , it works if I move the start before. |
From @NathanaelA on February 17, 2016 19:49 Yes. However, on iOS once you do an application.start() nothing below it is ran. ;-( Please note, I did a quick search of the tns-core-modules for getApplicationContext() and it is used in several places like filesystem, and platform. The good news is that this bug shouldn't be too wide spread as far as I can tell. Most people probably leave their app.js file alone... |
From @Daxito on February 17, 2016 19:53 Well, I can also move that to my home page instead. |
From @NathanaelA on February 17, 2016 20:54 Here is a workaround I'm using in my app:
|
Hey folks, I've just submitted pull request related to this issue. The error in this case was caused by the fact that Let me know what you think! Thanks |
This comment was marked as abuse.
This comment was marked as abuse.
Hey @slavchev, @atanasovg Can you help here? |
@NathanaelA You are correct - this used to work prior 1.6. The behavioral change is caused by the snapshot refactoring pull because the This exception is generally a quirk in the Runtime itself and we may have this behavior improved by simply tracking the initialization process via some Now, I guess I haven't estimated well the impact of this change - my thinking was that it shouldn't be hit by the users and obviously my assumption was wrong. Your scenarios are perfectly valid and if this turns to be a show-stopper we will definitely push a hot fix for it. |
This comment was marked as abuse.
This comment was marked as abuse.
NativeScript/android@a89aa46 fixes the issue, we need to prepare a hot fix for the Android Runtime. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
From @Daxito on February 17, 2016 16:30
I just upgraded to 1.6.0 from 1.5.2 and now I get this error when trying to run the app on android, ios is ok:
Any clue? If I create a new project it works ok, seems like a problem with my existing app only, this is my exception log:
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:
Calling js method onCreate failed
Error: java.lang.RuntimeException: NativeScriptApplication already initialized
com.tns.Platform.init(Platform.java:105)
com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:1033)
com.tns.Platform.callJSMethodNative(Native Method)
com.tns.Platform.dispatchCallJSMethodNative(Platform.java:812)
com.tns.Platform.callJSMethod(Platform.java:711)
com.tns.Platform.callJSMethod(Platform.java:690)
com.tns.Platform.callJSMethod(Platform.java:680)
com.tns.NativeScriptApplication.onCreateInternal(NativeScriptApplication.java:924)
com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:1037)
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
android.app.ActivityThread.handleBindApplication(ActivityThread.java:5010)
android.app.ActivityThread.access$1600(ActivityThread.java:172)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:145)
android.app.ActivityThread.main(ActivityThread.java:5835)
java.lang.reflect.Method.invoke(Native Method)
java.lang.reflect.Method.invoke(Method.java:372)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
File: ", line: 0, column: -1
StackTrace:
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5013)
at android.app.ActivityThread.access$1600(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5835)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: com.tns.NativeScriptException:
Calling js method onCreate failed
Error: java.lang.RuntimeException: NativeScriptApplication already initialized
com.tns.Platform.init(Platform.java:105)
com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:1033)
com.tns.Platform.callJSMethodNative(Native Method)
com.tns.Platform.dispatchCallJSMethodNative(Platform.java:812)
com.tns.Platform.callJSMethod(Platform.java:711)
com.tns.Platform.callJSMethod(Platform.java:690)
com.tns.Platform.callJSMethod(Platform.java:680)
com.tns.NativeScriptApplication.onCreateInternal(NativeScriptApplication.java:924)
com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:1037)
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
android.app.ActivityThread.handleBindApplication(ActivityThread.java:5010)
android.app.ActivityThread.access$1600(ActivityThread.java:172)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:145)
android.app.ActivityThread.main(ActivityThread.java:5835)
java.lang.reflect.Method.invoke(Native Method)
java.lang.reflect.Method.invoke(Method.java:372)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
File: ", line: 0, column: -1
StackTrace:
at com.tns.Platform.callJSMethodNative(Native Method)
at com.tns.Platform.dispatchCallJSMethodNative(Platform.java:812)
at com.tns.Platform.callJSMethod(Platform.java:711)
at com.tns.Platform.callJSMethod(Platform.java:690)
at com.tns.Platform.callJSMethod(Platform.java:680)
at com.tns.NativeScriptApplication.onCreateInternal(NativeScriptApplication.java:924)
at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:1037)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5010)
... 9 more
Caused by: java.lang.RuntimeException: NativeScriptApplication already initialized
at com.tns.Platform.init(Platform.java:105)
at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:1033)
... 18 more
Copied from original issue: NativeScript/nativescript-cli#1497
The text was updated successfully, but these errors were encountered: