Thanks to visit codestin.com
Credit goes to github.com

Skip to content

@nativescript/core 8.5.4+: ReferenceError androidApp is not defined #10323

Closed
@felixkrautschuk

Description

@felixkrautschuk

Issue Description

After upgrading @nativescript/core from 8.5.3 to 8.5.4 (or latest 8.5.6), our Android app is crashing for Android 8 and below when calling the connectivity startMonitoring method.

//app.js

const applicationModule = require("@nativescript/core/application");
const connectivityModule = require("@nativescript/core/connectivity");

applicationModule.on(applicationModule.suspendEvent, function(args) {
  connectivityModule.stopMonitoring();
});


applicationModule.on(applicationModule.resumeEvent, function(args) {
  connectivityModule.startMonitoring(function(newConnectionType) {
    console.log(newConnectionType);
  });
});

applicationModule.run({ moduleName: 'app-root' });

Reproduction

app for reproduction:
nsandroidcrash.zip

Just start the app on Android 8 or below, then you will see the crash.

Relevant log output (if applicable)

System.err: java.lang.RuntimeException: Unable to resume activity {org.nativescript.nsandroidcrash/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onPostResume failed
  System.err: ReferenceError: androidApp is not defined
  System.err:   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3429)
  System.err:   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469)
  System.err:   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732)
  System.err:   at android.app.ActivityThread.-wrap12(ActivityThread.java)
  System.err:   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
  System.err:   at android.os.Handler.dispatchMessage(Handler.java:102)
  System.err:   at android.os.Looper.loop(Looper.java:154)
  System.err:   at android.app.ActivityThread.main(ActivityThread.java:6119)
  System.err:   at java.lang.reflect.Method.invoke(Native Method)
  System.err:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
  System.err:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
  System.err: Caused by: com.tns.NativeScriptException: Calling js method onPostResume failed

Environment

OS: macOS 13.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Shell: /bin/zsh
node: 16.17.0
npm: 8.19.3
nativescript: 8.5.3

# android
java: 11.0.11
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: 14.3.1/14E300c
cocoapods: 1.12.1
python: 2.7.18
python3: 3.9.6
ruby: 2.6.10
platforms: 
  - DriverKit 22.4
  - iOS 16.4
  - macOS 13.3
  - tvOS 16.4
  - watchOS 9.4

Dependencies

"dependencies": {
  "@nativescript/core": "^8.5.6"
},
"devDependencies": {
  "@nativescript/android": "8.5.0",
  "@nativescript/webpack": "^5.0.16"
}

Please accept these terms

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions