03-16 19:19:19.523 8197 8197 D TNS.Runtime: V8 version 8.3.110.9
03-16 19:19:19.907 8197 8197 D AndroidRuntime: Shutting down VM
03-16 19:19:19.908 8197 8197 E AndroidRuntime: FATAL EXCEPTION: main
03-16 19:19:19.908 8197 8197 E AndroidRuntime: Process: org.nativescript.nsmscheckbox, PID: 8197
03-16 19:19:19.908 8197 8197 E AndroidRuntime: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function
03-16 19:19:19.908 8197 8197 E AndroidRuntime: TypeError: Cannot read property 'widget' of undefined
03-16 19:19:19.908 8197 8197 E AndroidRuntime: File: (file:///data/data/org.nativescript.nsmscheckbox/files/app/vendor.js:2:760452)
03-16 19:19:19.908 8197 8197 E AndroidRuntime:
03-16 19:19:19.908 8197 8197 E AndroidRuntime: StackTrace:
03-16 19:19:19.908 8197 8197 E AndroidRuntime: 19827(file:///data/data/org.nativescript.nsmscheckbox/files/app/vendor.js:2:760453)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at __webpack_require__(file:///data/data/org.nativescript.nsmscheckbox/files/app/runtime.js:1:197)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at 8898(file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:111741)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at __webpack_require__(file:///data/data/org.nativescript.nsmscheckbox/files/app/runtime.js:1:197)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at __webpack_exec__(file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112199)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at (file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112276)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at __webpack_require__.X(file:///data/data/org.nativescript.nsmscheckbox/files/app/runtime.js:1:1182)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at (file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112212)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at (file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112443)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at require(:1:266)
03-16 19:19:19.908 8197 8197 E AndroidRuntime:
03-16 19:19:19.908 8197 8197 E AndroidRuntime:
03-16 19:19:19.908 8197 8197 E AndroidRuntime: TypeError: Cannot read property 'widget' of undefined
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6717)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:237)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at android.os.Looper.loop(Looper.java:223)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7656)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: Caused by: com.tns.NativeScriptException: Error calling module function
03-16 19:19:19.908 8197 8197 E AndroidRuntime: TypeError: Cannot read property 'widget' of undefined
03-16 19:19:19.908 8197 8197 E AndroidRuntime: File: (file:///data/data/org.nativescript.nsmscheckbox/files/app/vendor.js:2:760452)
03-16 19:19:19.908 8197 8197 E AndroidRuntime:
03-16 19:19:19.908 8197 8197 E AndroidRuntime: StackTrace:
03-16 19:19:19.908 8197 8197 E AndroidRuntime: 19827(file:///data/data/org.nativescript.nsmscheckbox/files/app/vendor.js:2:760453)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at __webpack_require__(file:///data/data/org.nativescript.nsmscheckbox/files/app/runtime.js:1:197)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at 8898(file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:111741)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at __webpack_require__(file:///data/data/org.nativescript.nsmscheckbox/files/app/runtime.js:1:197)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at __webpack_exec__(file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112199)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at (file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112276)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at __webpack_require__.X(file:///data/data/org.nativescript.nsmscheckbox/files/app/runtime.js:1:1182)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at (file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112212)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at (file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112443)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at require(:1:266)
03-16 19:19:19.908 8197 8197 E AndroidRuntime:
03-16 19:19:19.908 8197 8197 E AndroidRuntime:
03-16 19:19:19.908 8197 8197 E AndroidRuntime: TypeError: Cannot read property 'widget' of undefined
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at com.tns.Runtime.runModule(Native Method)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at com.tns.Runtime.runModule(Runtime.java:689)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at com.tns.Runtime.run(Runtime.java:681)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
03-16 19:19:19.908 8197 8197 E AndroidRuntime: ... 8 more
03-16 19:19:19.911 513 2089 I am_crash: [8197,0,org.nativescript.nsmscheckbox,816365124,com.tns.NativeScriptException,Error calling module function
03-16 19:19:19.911 513 2089 I am_crash: TypeError: Cannot read property 'widget' of undefined
03-16 19:19:19.911 513 2089 I am_crash: File: (file:///data/data/org.nativescript.nsmscheckbox/files/app/vendor.js:2:760452)
03-16 19:19:19.911 513 2089 I am_crash:
03-16 19:19:19.911 513 2089 I am_crash: StackTrace:
03-16 19:19:19.911 513 2089 I am_crash: 19827(file:///data/data/org.nativescript.nsmscheckbox/files/app/vendor.js:2:760453)
03-16 19:19:19.911 513 2089 I am_crash: at __webpack_require__(file:///data/data/org.nativescript.nsmscheckbox/files/app/runtime.js:1:197)
03-16 19:19:19.911 513 2089 I am_crash: at 8898(file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:111741)
03-16 19:19:19.911 513 2089 I am_crash: at __webpack_require__(file:///data/data/org.nativescript.nsmscheckbox/files/app/runtime.js:1:197)
03-16 19:19:19.911 513 2089 I am_crash: at __webpack_exec__(file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112199)
03-16 19:19:19.911 513 2089 I am_crash: at (file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112276)
03-16 19:19:19.911 513 2089 I am_crash: at __webpack_require__.X(file:///data/data/org.nativescript.nsmscheckbox/files/app/runtime.js:1:1182)
03-16 19:19:19.911 513 2089 I am_crash: at (file:///data/data/org.nativescript.nsmscheckbox/files/app/bundle.js:1:112212)
Description The app can run in debug mode but it crashes in Android device when adding nativescript-checkbox to a Nativescript 8.2.2 project.
The 2 lines of plugin code may not work as intended:
https://github.com/nstudio/nativescript-plugins/blob/main/packages/nativescript-checkbox/index.android.ts#:~:text=const%20AppCompatCheckBox_Namespace%20%3D%20useAndroidX()%20%3F%20androidx.appcompat.widget%20%3A%20(android.support%20as%20any).v7.widget%3B
https://github.com/nstudio/nativescript-plugins/blob/main/packages/nativescript-checkbox/index.android.ts#:~:text=const%20CompoundButtonCompat_Namespace%20%3D%20useAndroidX()%20%3F%20androidx.core.widget%20%3A%20(android.support.v4%20as%20any).widget%3B
Somehow the global variables:
global.androidx , com.google , com.google.android and com.google.android.material
don't contain expected values.Environment and code repository Nativescript: CLI 8.2.2 JAVA: openjdk version "11.0.14.1" 2022-02-08 LTS Node: v14.17.0 Npm: 6.14.13 Android Studio: Bumblebee | 2021.1.1 Patch 2 Android SDK: 31,30,29,28 Code repository: https://github.com/banchasf/nscheckbox
Error message