title: MLKit for object detection for Android problem
body: <p>I am trying to learn how to use ML-kit for Android for object detection. I wanted to choose an image from gallery and detect it in the device. My code is as follows:</p>
  <p>First, I initialized Firebase a by :</p>
  <pre><code>FirebaseApp.initializeApp(this)
  </code></pre>
  <p>Then, I created a listener for button as</p>
  <pre><code> btnChooseImage.setOnClickListener {
          var intent = Intent()
          intent.type = &quot;image/*&quot;
          intent.action = Intent.ACTION_GET_CONTENT
          startActivityForResult(Intent.createChooser(intent, &quot;select Image&quot;), 111)
      }
  </code></pre>
  <p>Then, after choosing image, I performed following code:</p>
  <pre><code>override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
      super.onActivityResult(requestCode, resultCode, data)
      if (requestCode == 111) {
          imvImageRec.setImageURI(data?.data)
  
          val image: FirebaseVisionImage
          try {
              image = FirebaseVisionImage.fromFilePath(applicationContext, data?.data!!)
  
              val labeler: FirebaseVisionImageLabeler = FirebaseVision.getInstance().onDeviceImageLabeler
              labeler.processImage(image).addOnSuccessListener {
                  for (label in it) {
                      val text = label.text
                      val entityId = label.entityId
                      val confidence = label.confidence
  
                      txvRecognizedImageText.append(&quot;$text   $confidence\n&quot;)
                  }
              }.addOnFailureListener {
  
              }
          } catch (e: IOException) {
              e.printStackTrace()
          }
      }
  }
  </code></pre>
  <p>I am having the problem in the line</p>
  <pre><code>val labeler: FirebaseVisionImageLabeler = FirebaseVision.getInstance().onDeviceImageLabeler
  </code></pre>
  <p>It says <code>NullPointerException</code>.</p>
  <blockquote>
  <p>Caused by: java.lang.NullPointerException: Attempt to invoke virtual
  method 'com.google.firebase.ml.vision.label.FirebaseVisionImageLabeler
  com.google.firebase.ml.vision.FirebaseVision.getOnDeviceImageLabeler()'
  on a null object reference
  at com.example.ObjectDetection.ObjectDetectionActivity.onActivityResult(ObjectDetectionActivity.kt:42)</p>
  </blockquote>
  <p>Could anyone please help me?</p>