3

Related to : Error: onActivityResult overrides nothing

I've tried Dhaval Patel's solution and get the report that it overrides nothing from my parser. Omitting the override annotation reports that it hides the super method and override is required. Is there an issue with my parser?

How the documentation says to implement the method (which won't compile) https://developer.android.com/training/basics/intents/result

How I only get a parser warning - overrides nothing, override redundant

override fun onActivityResult(requestCode:Int, resultCode:Int, data:Intent?) 

How I get a compile error - override annotation required:

fun onActivityResult(requestCode:Int, resultCode:Int, data:Intent?)
James Bone
  • 576
  • 1
  • 4
  • 9
  • I'm going to take a complete shot in the dark here... Does changing the data type from `Intent?` to `Intent` allow you to compile? – byxor Jan 09 '19 at 02:10
  • No. Intent is nullable because the parent class is in Java (android.support.v7.app.AppCompatActivity) – James Bone Jan 09 '19 at 03:04
  • 1
    According to [this tutorial](https://www.raywenderlich.com/500-introduction-to-android-activities-with-kotlin), you'll need Kotlin 1.2.71 & Android Studio 3.2.1. Do you have high enough versions of these? – byxor Jan 09 '19 at 03:22
  • byxor: yes, those are the exact version numbers I'm using. I saw that tutorial and while I didn't download their code their snippet on that section doesn't seem to mention it. – James Bone Jan 09 '19 at 03:59

1 Answers1

1

Thanks to a clue from byxor, I checked my build.grade

My IDE (Android Studio) reported a version mismatch in it's Kotlin version and the documentation. I've upgraded to 1.3.11 and it's resolved the issue by recognizing the need for the override annotation.

James Bone
  • 576
  • 1
  • 4
  • 9
  • I found some additional faults with my build.gradle that were related. I've put them up on my blog: https://www.designanddata.net/wordpress/2019/01/10/kotlin-for-android-with-room/ – James Bone Jan 10 '19 at 02:14