Got this error in play console kotlin.UninitializedPropertyAccessException Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Got this error in play console kotlin.UninitializedPropertyAccessException without wasting too much if your time.

The question is published on by Tutorial Guruji team.

Play console screenshot kotlin.UninitializedPropertyAccessException: at com.videoplayer.VideoPlayerActivity.onStart (VideoPlayerActivity.kt:224) at ( at ( at ( at ( at ( at ( at ( at$H.handleMessage (

Defining variables

private var captionIconVisibility: Boolean = false
    private  var videoStarted: Boolean=false
    private  var lastItemPosition: Int = 1
    private  var itemsCount: Int = 1
    private var videoWatchedTime: Long=0
    private var isPreparing: Boolean=true
    private lateinit var currentPlayingPlayList: List<ObjectVideo>
    private lateinit var sharedPrefMemory: SharedPrefMemory
    private lateinit var mCastApplication: CastApplication
    private lateinit var player: SimpleExoPlayer
    private var isAdPlaying: Boolean =false
    private lateinit var mediaPlayer: MediaPlayer
  //  private lateinit var dtm: DTM
    private lateinit var adPlayerManger: AdPlayerManger
    private var podSize = 1
    private var adType = "midroll"
    private var videoPaused: Boolean = false
    private lateinit var objectVideo: ObjectVideo
    var currentPlayingVodPosition = 0
    private var previousVideoPositionNumber=-1
    private var playBackPosition:Long=0
    private var numberOfVideoWatched: Int=0
    private var isCaptionsOff : Boolean = false
    private var isInfoLayoutVisible:Boolean = false
    private lateinit var binding: ActivityVideoPlayerBinding
    private lateinit var videoPlayerActivityVM: VideoPlayerActvityVM
    private var midAdPositionList = ArrayList<Long>()
    private var runnable: Runnable? = null
    private val mHandler: Handler = Handler()
    private var watchedVideoStatus: HashMap<String, Long>? = null
    private lateinit var bottomSheetBehavior :BottomSheetBehavior<View>
    private lateinit var bottomSheetRv: RecyclerView
    private lateinit var bottomSheetPlaylistAdapter: BottomSheetPlaylistAdapter
    private var bottomSheetList = ArrayList<ObjectVideo>()
    private var resumedPosition:Long=0
    private var pageNumber:Int =1
    private var url : String = ""
    private var isPreviousClicked: Boolean = false
    private lateinit var mDetector: GestureDetectorCompat
    private lateinit var vods:ArrayList<ObjectVideo>

    companion object {
         var dtm:DTM = DTM()
      //    var vods: ArrayList<ObjectVideo> = ArrayList()

My OnCreate method

override fun onCreate(savedInstanceState: Bundle?) {
        binding = DataBindingUtil.setContentView(this, R.layout.activity_video_player)

        // flags to make media player screen full screen
        bottomSheetBehavior = BottomSheetBehavior.from(binding.bottomsheetView.bottomSheetLayout)
        bottomSheetRv = binding.bottomsheetView.bottomSheetRv

        sharedPrefMemory = SharedPrefMemory(this, Context.MODE_PRIVATE, true)

//        val mToolbar = binding.toolbarMediaPlayer as Toolbar
//        setSupportActionBar(mToolbar)
//        supportActionBar!!.setDisplayShowTitleEnabled(false)

        val intentObj = intent
      //  dtm = intentObj.getSerializableExtra("dtm") as DTM

      try {
          vods = dtm.videoArrayList

          bottomSheetList = vods
          currentPlayingVodPosition = dtm.position
          url = dtm.url
          if (!(vods.size>0 && currentPlayingVodPosition<vods.size)){

 = vods[currentPlayingVodPosition]
          mediaPlayer = PlayerBuilder.getMediaPlayer(this, dtm, vods)
          objectVideo = vods[currentPlayingVodPosition]

      catch (e:java.lang.Exception){
          Toast.makeText(this,"Something went wrong",Toast.LENGTH_SHORT).show()


        videoPlayerActivityVM = ViewModelProviders.of(this)[]

        videoPlayerActivityVM.getMoreVideosList().observe(this, androidx.lifecycle.Observer<List<ObjectVideo>> { moreVideosList ->
            if (moreVideosList.isNotEmpty()) {
            } else {
                GlobalObject.hasMoreDataMap[url] = false


        mCastApplication = CastApplication(this, this)

Below is my OnStart Method

 override fun onStart() {
        Log.d("LifeCycle", "OnStart is called")
        if (true) {
            player = mediaPlayer.getPlayer()
            isCaptionsOff = sharedPrefMemory.subtitlePreference
            binding.exoPlayerView.player = player

            //var pos:Long=0



            videoPaused = false



I don’t have line numbers so I’m just guessing here.

Take a look at onCreate:

try {
    vods = dtm.videoArrayList
    // ...
    mediaPlayer = PlayerBuilder.getMediaPlayer(this, dtm, vods)
    objectVideo = vods[currentPlayingVodPosition]
} catch (e: Exception) {
      Toast.makeText(this,"Something went wrong",Toast.LENGTH_SHORT).show()

So when PlayerBuilder.getMediaPlayer(this, dtm, vods) or anything before that fails

  1. mediaPlayer remains uninitialized,
  2. user gets a toast but you as a developer get no exception report,
  3. player = mediaPlayer.getPlayer() happens during onStart which casues a crash because (1).

I don’t have a fix for you, the code is huge, hard to read and hard to reason about. Good luck fixing it.

We are here to answer your question about Got this error in play console kotlin.UninitializedPropertyAccessException - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji