Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashing sometimes, findViewById(R.id.search_layout) returning null #248

Open
suraj-vaish9av opened this issue Jan 25, 2021 · 0 comments

Comments

@suraj-vaish9av
Copy link

In MaterialSearchView there is a method initiateView in which the following statement:
mSearchLayout = findViewById(R.id.search_layout);
returning null sometime that is why the subsequent statement :
mSearchTopBar = (RelativeLayout) mSearchLayout.findViewById(R.id.search_top_bar);
throwing an exception.

Here is the log from firebase crashlytics:

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
       at com.miguelcatalan.materialsearchview.MaterialSearchView.initiateView(MaterialSearchView.java:146)
       at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:93)
       at com.miguelcatalan.materialsearchview.MaterialSearchView.<init>(MaterialSearchView.java:85)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
       at android.view.LayoutInflater.createView(LayoutInflater.java:652)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:812)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:883)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:522)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
       at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
       at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
       at com.orderaxe.ajm.ui.home.HomeActivity.onCreate(HomeActivity.kt:97)
       at android.app.Activity.performCreate(Activity.java:6868)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2676)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2784)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1523)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:163)
       at android.app.ActivityThread.main(ActivityThread.java:6238)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant