question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

startRecording fails on android X ?

See original GitHub issue

2.0.1

flutter doctor

flutter doctor -v [✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Linux, locale en_AU.UTF-8) • Flutter version 1.12.13+hotfix.5 at /home/bsutton/apps/flutter • Framework revision 27321ebbad (6 weeks ago), 2019-12-10 18:15:01 -0800 • Engine revision 2994f7e1e6 • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /home/bsutton/Android/Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • Java binary at: /home/bsutton/apps/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.

[✓] Android Studio (version 3.5) • Android Studio at /home/bsutton/apps/android-studio • Flutter plugin version 42.1.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (1 available) • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found!

Platforms you faced the error (IOS or Android or both?)

Android

Expected behavior

When I call startRecording the system should start recording.

Actual behavior

The call to startRecording fails silently.

Tested environment (Emulator? Real Device?)

Emulator

Steps to reproduce the behavior

Call startRecording.

So I’ve dug into the code and found the source of the error: The method: checkRecordPermission in FlutterSoundPlugin.java (line 42) calls: reg.activity() which is returning a null.

Line 44 then passes the null activity to : ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.RECORD_AUDIO,}, 0);

The call to requestPermissions then throws an NPE.

Looking at the documentation I suspect this is occurring as I’m running a later version of Flutter/Dart.

The documentation on Registrar.activty() has instructions for migrating a plugin from Flutters v1 embedding to Flutters v2 embedding. It would appear that flutter_sound is still using the v1 method which is why I suspect this bug is showing up now.

So it looks like the code needs to be migrated as per:

For instructions on migrating a plugin from Flutter’s v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Can I also suggest that you put a try/catch block around each top level method so that you can log and report an appropriate error to the calling application rather than just failing silently.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MichalMisiaszekcommented, Jan 28, 2020

So I pulled latest version 2.0.3 and method String _file = await _flutterSound.startRecorder(uri: _soundFilename); seems to be doing nothing.

1reaction
Larpouxcommented, Jan 26, 2020

Yes, this could be a good planing. I am not a flutter expert, but my first tries to be compatible with V1 and V2 is encouraging. Flutter documentation is good, and there is no much code to be compatible.

I will take you inform later (this evening or tomorrow) of my advancement.

Read more comments on GitHub >

github_iconTop Results From Across the Web

startRecording fails on android X ? #203 - flutter doctor
For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration.
Read more >
My Audio Recording App Is Failing To Start Recording
My Audio Recording App Is Failing To Start Recording ... AppCompatActivity; import androidx.core.app.ActivityCompat; import android.
Read more >
Android Question Failed start recording-AudioStremer
I tried this example: https://www.b4x.com/android/forum/threads/audio-library-v1-5-new-audiostreamer-object.30550/#content I didn't modify ...
Read more >
Video Recording while in phone call fails silently [183952600 ...
The recorded video without audio. It looks like no audio frame received. Log. 2021-04-22 15:10:50.528 18722-18722/androidx.
Read more >
MediaRecorder
Applications may want to register for informational and error events in order to ... Register a callback to be invoked when an error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found