IllegalArgumentException: Cannot add a null child view to a ViewGroup (after updating from 10.0.0-rc.5 to rc.6)

See original GitHub issue

Environment

  • CLI: 6.8.0-rc.4
  • Cross-platform modules: 7.0.0-rc.24
  • Android Runtime: 6.5.3
  • iOS Runtime: 6.5.2
  • Plugin(s): nativescript-google-maps-sdk, nativescript-oauth2, nativescript-ui-dataform
  • NativeScript-Angular: 10.0.0-rc.6
  • Angular: 10.0.4

Describe the bug After updating @nativescript/angular the application won’t launch on Android (emulator or real device), showing the following error:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to start activity ComponentInfo{it.italdev.potpot.nsapp/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
System.err: 
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{it.italdev.potpot.nsapp/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
System.err:     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
System.err:     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
System.err:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
System.err:     at android.os.Looper.loop(Looper.java:193)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6669)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
System.err: Caused by: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err:     at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
System.err:     at android.app.Activity.performCreate(Activity.java:7136)
System.err:     at android.app.Activity.performCreate(Activity.java:7127)
System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
System.err:     ... 11 more
System.err: Caused by: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
System.err:     at android.view.ViewGroup.addView(ViewGroup.java:4857)
System.err:     at android.view.ViewGroup.addView(ViewGroup.java:4837)
System.err:     at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:478)
System.err:     at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:150)
System.err:     ... 22 more

To Reproduce

  1. create an angular code sharing project
  2. update @nativescript/angular from rc.5 to rc.6

Expected behavior The application should start without any error

Sample project I cannot share my project, but I can create a sample, the problem is that I’m working with some plugins that I’m updating.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
funder7commented, Aug 16, 2020

Closing: solved by following “Upgrading tips for Angular 10 projects” blog post.

image

1reaction
lonemanotzicommented, Jul 29, 2020

This is reproduceable in a shared project. (only shared project has this issue) Created a sample project by running command: ng new -c=@nativescript/schematics sass-project --shared --style=scss run ng serve Everything is working great. run nsc run android --emulator this generates the error@funder7 reported.,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot add a null child view to a ViewGroup - Stack Overflow
was sending a null value and that caused the error of "Cannot add a null child view to a ViewGroup". then when i...
Read more >
Cannot add a null child view to a ViewGroup when dismissing ...
java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup when dismissing main menu.
Read more >
Cant Add View to Viewgroup - ADocLib
IllegalArgumentException : Cannot add a null child view to a ViewGroup after updating from 10.0.0rc.5 to rc.6 #2197. My app crashes instantly when...
Read more >
addapptr / AATKitExample-Android / issues / #5 - java.lang ...
java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3421.
Read more >
Upgrading tips for Angular 10 projects - The NativeScript Blog
IllegalArgumentException : Cannot add a null child view to a ViewGroup Root should be either UIViewController or UIView.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found