I uploaded my first jetpack compose app and I’m ge...
# compose
a
I uploaded my first jetpack compose app and I’m getting a lot of crashes that I can’t reproduce on my devices.
Copy code
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.ViewGroup.getChildAt(int)' on a null object reference
at androidx.activity.compose.ComponentActivityKt.setContent (ComponentActivityKt.java:264)
  at com.censored.censored.presentation.MainActivity.onCreate (MainActivity.java:264)
Full crash in thread -> MainActivity line 264 points to a DrawerItem: (first line is 264)
Copy code
DrawerItem(
    imageDrawable = R.drawable.gold,
    title = "Text"
) {
    uriHandler.openUri("<https://google.com>")

}
Someone has an idea how I can fix it?
Copy code
Exception java.lang.RuntimeException:
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3520)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3692)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:85)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2142)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:236)
  at android.app.ActivityThread.main (ActivityThread.java:7864)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:620)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1011)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.ViewGroup.getChildAt(int)' on a null object reference
  at androidx.activity.compose.ComponentActivityKt.setContent (ComponentActivityKt.java:264)
  at com.censored.censored.presentation.MainActivity.onCreate (MainActivity.java:264)
  at android.app.Activity.performCreate (Activity.java:8109)
  at android.app.Activity.performCreate (Activity.java:8083)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1309)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3493)
Could it be that the image is called “gold” which is also a color? I renamed it to something else now
z
Can you file a bug for this (then post the link here)? I can see why it’s crashing, but not sure in what situations the content view would be null. Gonna do a bit more research
201 Views