Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Exception #4

Closed
incafox opened this issue Dec 25, 2018 · 6 comments
Closed

Fatal Exception #4

incafox opened this issue Dec 25, 2018 · 6 comments
Assignees

Comments

@incafox
Copy link

incafox commented Dec 25, 2018

hi, i was trying to add your plugin to a new project in order to run the example, and i have this error:
(i modified the manifest and adding the MainApplication file)

D/AndroidRuntime( 5855): Shutting down VM
E/AndroidRuntime( 5855): FATAL EXCEPTION: main
E/AndroidRuntime( 5855): Process: com.ryanheise.audioserviceexample, PID: 5855
E/AndroidRuntime( 5855): java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.PluginRegistry$PluginRegistrantCallback.registerWith(io.flutter.plugin.common.PluginRegistry)' on a null object reference
E/AndroidRuntime( 5855): at com.ryanheise.audioservice.AudioServicePlugin$ClientHandler$3.onPlay(AudioServicePlugin.java:218)
E/AndroidRuntime( 5855): at com.ryanheise.audioservice.AudioService$MediaSessionCallback$1.run(AudioService.java:396)
E/AndroidRuntime( 5855): at com.ryanheise.audioservice.AudioService$MediaSessionCallback.play(AudioService.java:411)
E/AndroidRuntime( 5855): at com.ryanheise.audioservice.AudioService$MediaSessionCallback.onPlay(AudioService.java:394)
E/AndroidRuntime( 5855): at android.support.v4.media.session.MediaSessionCompat$Callback$StubApi21.onPlay(MediaSessionCompat.java:1259)
E/AndroidRuntime( 5855): at android.support.v4.media.session.MediaSessionCompatApi21$CallbackProxy.onPlay(MediaSessionCompatApi21.java:194)
E/AndroidRuntime( 5855): at android.media.session.MediaSession$CallbackMessageHandler.handleMessage(MediaSession.java:1407)
E/AndroidRuntime( 5855): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 5855): at android.os.Looper.loop(Looper.java:164)
E/AndroidRuntime( 5855): at android.app.ActivityThread.main(ActivityThread.java:6494)
E/AndroidRuntime( 5855): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 5855): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
E/AndroidRuntime( 5855): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

i cannot run the example,i can run it only openning the plugin project itself (but obviously that is not the way), what am i doing wrong?

@ryanheise
Copy link
Owner

Hi, the error points to line 218 of AudioServicePlugin.java:

	pluginRegistrantCallback.registerWith(backgroundFlutterView.getPluginRegistry());

so, most likely pluginRegistrantCallback is null. Can you check that you have set the pluginRegistrantCallback in your MainApplication class? (an example is on the README page)

@ryanheise ryanheise self-assigned this Dec 26, 2018
@alexantenna
Copy link

I've stepped in similar problem myself. Default Flutter app structure doesn't include any custom MainApplication and not being Android developer before I've missed this light remark in the README. There are also a couple of other similar problems which I've finally solved by carefully investigated structure of the Example app and contents of all its files then copied the relevant parts to my app.

@incafox
Copy link
Author

incafox commented Dec 26, 2018

Hi, the error points to line 218 of AudioServicePlugin.java:

	pluginRegistrantCallback.registerWith(backgroundFlutterView.getPluginRegistry());

so, most likely pluginRegistrantCallback is null. Can you check that you have set the pluginRegistrantCallback in your MainApplication class? (an example is on the README page)

Thanks for the answer.
Yes i have set the pluginRegistrantCallback in my MainApplication like the README page, you can see that here :
https://github.com/incafox/audioserviceexample
I uploaded the entire example.
As @alexantenna said, i carefully investigated the structure of the example and i can't find the error, please help.

@alexantenna
Copy link

@incafox Looks like you didn't put reference to MainApplication to AndroidManifest.

The relevant part should look like:

<application
android:name=".MainApplication"
...

but you have reference to standard Flutter app (default value).

You should inspect manifest carefully as well :-) This was not easy for me!

P.S. Next hint - when your app starts partially working and you see the notification to see buttons icons you should copy files from src/res folder as well :-)

@incafox
Copy link
Author

incafox commented Dec 26, 2018

@incafox Looks like you didn't put reference to MainApplication to AndroidManifest.

The relevant part should look like:

<application
android:name=".MainApplication"
...

but you have reference to standard Flutter app (default value).

You should inspect manifest carefully as well :-) This was not easy for me!

P.S. Next hint - when your app starts partially working and you see the notification to see buttons icons you should copy files from src/res folder as well :-)

Thankyou!!! so much. :)

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants