Garmaine Staff asked 2 years ago

Hey guys I have problem with starting my app, I don't know what is the problem, it just crashes right away when I start it, from the log I suppose it is something about databinding but I don't really know what's wrong right now :C

2020-04-10 22:22:22.716 32624-32624/? I/rss.ing_projec: Late-enabling -Xcheck:jni
2020-04-10 22:22:22.746 32624-32624/? E/rss.ing_projec: Unknown bits set in runtime_flags: 0x8000
2020-04-10 22:22:23.053 32624-32624/com.lswarss.ing_project I/Perf: Connecting to perf service.
2020-04-10 22:22:23.070 32624-32624/com.lswarss.ing_project V/Font: Change font:1
2020-04-10 22:22:23.071 32624-32624/com.lswarss.ing_project V/Font: Default family:android.graphics.Typeface@177a2b82
2020-04-10 22:22:23.077 32624-32676/com.lswarss.ing_project E/Perf: Fail to get file list com.lswarss.ing_project
2020-04-10 22:22:23.077 32624-32676/com.lswarss.ing_project E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2020-04-10 22:22:23.077 32624-32676/com.lswarss.ing_project E/Perf: Fail to get file list com.lswarss.ing_project
2020-04-10 22:22:23.078 32624-32676/com.lswarss.ing_project E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2020-04-10 22:22:23.156 32624-32624/com.lswarss.ing_project W/rss.ing_projec: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2020-04-10 22:22:23.157 32624-32624/com.lswarss.ing_project W/rss.ing_projec: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2020-04-10 22:22:23.213 32624-32624/com.lswarss.ing_project V/FlingOptimizerScroller: FlingOptimizerOverScroller Init
2020-04-10 22:22:23.251 32624-32624/com.lswarss.ing_project D/AndroidRuntime: Shutting down VM
2020-04-10 22:22:23.253 32624-32624/com.lswarss.ing_project E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.lswarss.ing_project, PID: 32624
    java.lang.RuntimeException: Failed to call observer method
        at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:226)
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:194)
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:185)
        at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:37)
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361)
        at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:300)
        at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:339)
        at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145)
        at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131)
        at androidx.fragment.app.Fragment.performStart(Fragment.java:2735)
        at androidx.fragment.app.FragmentStateManager.start(FragmentStateManager.java:365)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1194)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1356)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1434)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1497)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2625)
        at androidx.fragment.app.FragmentManager.dispatchStart(FragmentManager.java:2583)
        at androidx.fragment.app.Fragment.performStart(Fragment.java:2739)
        at androidx.fragment.app.FragmentStateManager.start(FragmentStateManager.java:365)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1194)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1356)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1434)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1497)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2625)
        at androidx.fragment.app.FragmentManager.dispatchStart(FragmentManager.java:2583)
        at androidx.fragment.app.FragmentController.dispatchStart(FragmentController.java:258)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:550)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1514)
        at android.app.Activity.performStart(Activity.java:7838)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3398)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2109)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7682)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
     Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter data
        at com.lswarss.ing_project.adapters.BindingAdaptersKt.bindRecyclerView(Unknown Source:7)
        at com.lswarss.ing_project.databinding.PostsFragmentBindingImpl.executeBindings(PostsFragmentBindingImpl.java:125)
2020-04-10 22:22:23.253 32624-32624/com.lswarss.ing_project E/AndroidRuntime:     at androidx.databinding.ViewDataBinding.executeBindingsInternal(ViewDataBinding.java:473)
        at androidx.databinding.ViewDataBinding.executePendingBindings(ViewDataBinding.java:445)
        at androidx.databinding.ViewDataBinding$OnStartListener.onStart(ViewDataBinding.java:1687)
        at java.lang.reflect.Method.invoke(Native Method)
        at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:216)
            ... 41 more

That's the log given by android studio And it have some problems with this class but what wrong with it:

package com.lswarss.ing_project.adapters

import android.view.View
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import androidx.recyclerview.widget.RecyclerView
import com.lswarss.ing_project.R
import com.lswarss.ing_project.domain.PostItem
import com.lswarss.ing_project.fragments.PostsApiStatus

@BindingAdapter("listData")
fun bindRecyclerView(recyclerView: RecyclerView, data: List<PostItem>?){
    val adapter  = recyclerView.adapter as PostsAdapter
    adapter.submitList(data)
}


@BindingAdapter("postApiStatus")
fun bindStatus(statusImageView: ImageView, status: PostsApiStatus?) {
    when (status) {
        PostsApiStatus.LOADING -> {
            statusImageView.visibility = View.VISIBLE
            statusImageView.setImageResource(R.drawable.loading_animation)
        }
        PostsApiStatus.ERROR -> {
            statusImageView.visibility = View.VISIBLE
            statusImageView.setImageResource(R.drawable.ic_connection_error)
        }
        PostsApiStatus.DONE -> {
            statusImageView.visibility = View.GONE
        }
    }
}

I was trying to do this application using the app made in udacity course Mars Real Estate App

Here is link to my app on github: https://github.com/LSWarss/ing_project The code I have problems with is on branch new_architecture

Sory if this is stupid question but I'm new to android and koltlin, or even posting on stack 🙂