nstudio / nstudio/nativescript-plugins

Crash in Android device when adding nativescript-checkbox to a Nativescript 8.2.2 project

Open
#85 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
55
Forks
42
Avg merge
49m
Merged PRs (30d)
1

Description

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:

  1. 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

  2. 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

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)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/nativescript-checkbox/index.android.ts, especially the AppCompatCheckBox_Namespace and CompoundButtonCompat_Namespace assignments, and reproduce the crash using the linked nscheckbox repository on an Android device. Confirm the AndroidX/support namespace behavior in NativeScript 8.2.2; done means adding the plugin no longer causes the reported 'widget' startup error.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.