Pass Data with Safe Args | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7503473-your-second-kotlin-android-app/lessons/44

Course was good up until the very last lesson. Was following along with my code from start to finish but the last episode crashed the app when trying to click a list to see the details. Downloaded the source code to see if I could get it running anyways and still got an error when clicking on a list to see the details:

  2020-04-05 18:52:48.969 21636-21636/com.raywenderlich.listmaker E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.raywenderlich.listmaker, PID: 21636
kotlin.UninitializedPropertyAccessException: lateinit property list has not been initialized
    at com.raywenderlich.listmaker.TaskDetailFragment.onViewCreated(TaskDetailFragment.kt:44)
    at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:892)
    at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100)
    at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874)
    at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
    at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
    at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:7770)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)

The error I got on the project I was using from start to finish was like this:

  2020-04-05 18:56:15.016 21117-21117/com.dannguyen.listmaker E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dannguyen.listmaker, PID: 21117
java.lang.IllegalStateException: view.findViewById(R.id.task_list_recyclerview) must not be null
    at com.dannguyen.listmaker.TaskDetailFragment.onViewCreated(TaskDetailFragment.kt:42)
    at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:892)
    at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100)
    at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874)
    at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
    at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
    at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:7770)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047) 

2020-04-05 18:56:15.037 21117-21117/com.dannguyen.listmaker I/Process: Sending signal. PID: 21117 SIG: 9

But task_list_recyclerview was in both activity_detail.xml and fragment_task_detail.xml

Yeah, that’s an interesting one. It’s a little hard to diagnose from the stack trace alone. Feel free to send the project to brian@razeware.com and I’ll take a look at what is going on. Thanks!

I liked the course until the end, I think a last lesson to go over everything together would tie it up since A LOT changed in this last Jetpack section. So sort of a small recap and lets go through each part of the code together wouldn’t be a bad thing. Also the list that was added last, Shopping, took place #2 when the list Coding was #2, maybe a reference to why or how to fix this ordering “feature” would be great.
Also at some point we used filter { predicate }[0], why not use “first/find”?

ViewModelProviders is deprecated. Please update the session accordingly.

Thanks for the feedback. I believe the updated version of this course is already in production. Cheers!