Home > front end >  I was doing Flutter app development in Android Studio, and I got an error in the Android build. Reco
I was doing Flutter app development in Android Studio, and I got an error in the Android build. Reco

Time:09-16

【Flutter】e: Class ‘SoundStreamPlugin’ is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult/e: ‘onRequestPermissionsResult’ overrides nothing The error message is as follows: (Split for better viewing)

e: /Users/UserName/development/flutter/.pub-cache/hosted/pub.dartlang.org/sound_stream-0.3.0/android/src/main/kotlin/vn/casperpas/sound_stream/SoundStreamPlugin.kt: (45, 8): Class 'SoundStreamPlugin' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
e: /Users/UserName/development/flutter/.pub-cache/hosted/pub.dartlang.org/sound_stream-0.3.0/android/src/main/kotlin/vn/casperpas/sound_stream/SoundStreamPlugin.kt: (182, 5): 'onRequestPermissionsResult' overrides nothing
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sound_stream:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Running Gradle task 'assembleDebug'...                           2,093ms
Exception: Gradle task assembleDebug failed with exit code 1

CodePudding user response:

/Users/UserName/development/flutter/.pub-cache/hosted/pub.dartlang.org/sound_stream-0.3.0/android/src/main/kotlin/vn/casperpas/sound_stream/SoundStreamPlugin.kt を開きます。

And look for onRequestPermissionsResult().

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>?, grantResults: IntArray?): Boolean {
  when (requestCode) {
    audioRecordPermissionCode -> {
      if (grantResults != null) {
        permissionToRecordAudio = grantResults.isNotEmpty() &&
          grantResults[0] == PackageManager.PERMISSION_GRANTED
      }
      completeInitializeRecorder()
      return true
    }
  }
  return false
}

The argument in this '?' Delete.

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray): Boolean {

Again, build on Android.

Success.

CodePudding user response:

please check on this link on how to ask a question on stackoverflow.

and to answer your question, it looks like an error from the sound_stream package itself. According to an issue posted here, there are some errors that have to do with null safety for flutter 3.0.1. check the solution posted there if it works for you, edit the package yourself. if it doesnt then i guess you will have to wait until the developer fixes it.

  • Related