Расширения Kotlin вызывают исключение NullPointerException в Firebase Crashlytics

#android #android-layout #kotlin-android-extensions

#Android #android-макет #kotlin-android-extensions

Вопрос:

  • Эта проблема не возникает на моих тестовых устройствах, начиная с Android 6 — Android 10.
  • Эта проблема возникает на тестовом телефоне клиента, Samsung Galaxy S20 Ultra 5G.
  • Попробовал себя на Samsung Galaxy S20 Ultra 5G, не смог воспроизвести.
  • Проблема видна в Firebase Crashlytics, но пока не может быть воспроизведена.
     apply plugin: 'kotlin-android-extensions'
    
    
    import kotlinx.android.synthetic.main.activity_main.*
    import kotlinx.android.synthetic.main.activity_main.view.*
    
    override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
    }
    
    private fun initializeViewPager(list: List<MyObject>) {
       adapter = TabFragmentAdapter(supportFragmentManager, fragments!!)
       val vp: ViewPager = list_container.viewPager // crash
       vp.adapter = adapter
    }
    
    <?xml version="1.0" encoding="utf-8"?>
    <layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools">
    
        <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@drawable/backgroundimagenew"
          android:orientation="vertical"
          tools:context=".MainActivity">
    
          <LinearLayout
              android:id="@ id/list_container"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">
    
          </LinearLayout>
    
        </LinearLayout>
    </layout>
     

Сбой в crashlytics:

 nl.companyname.android.ui.activities.MainActivity.initializeViewPager (MainActivity.kt:356)
nl.companyname.android.ui.activities.MainActivity.onLoadFinished (MainActivity.kt:335)
nl.companyname.android.ui.activities.MainActivity.onLoadFinished (MainActivity.kt:68)
androidx.loader.app.LoaderManagerImpl$LoaderObserver.onChanged (LoaderManagerImpl.java:250)
androidx.lifecycle.LiveData.considerNotify (LiveData.java:131)
androidx.lifecycle.LiveData.dispatchingValue (LiveData.java:149)
androidx.lifecycle.LiveData.setValue (LiveData.java:307)
androidx.lifecycle.MutableLiveData.setValue (MutableLiveData.java:50)
androidx.loader.app.LoaderManagerImpl$LoaderInfo.setValue (LoaderManagerImpl.java:189)
androidx.loader.app.LoaderManagerImpl$LoaderInfo.onLoadComplete (LoaderManagerImpl.java:174)
androidx.loader.content.Loader.deliverResult (Loader.java:132)
androidx.loader.content.AsyncTaskLoader.dispatchOnLoadComplete (AsyncTaskLoader.java:258)
androidx.loader.content.AsyncTaskLoader$LoadTask.onPostExecute (AsyncTaskLoader.java:83)
androidx.loader.content.ModernAsyncTask.finish (ModernAsyncTask.java:490)
androidx.loader.content.ModernAsyncTask$InternalHandler.handleMessage (ModernAsyncTask.java:507)
android.os.Handler.dispatchMessage (Handler.java:107)
android.os.Looper.loop (Looper.java:237)
android.app.ActivityThread.main (ActivityThread.java:8154)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)