颤振音频服务 ?? android.app.RemoteServiceException: Context.startForegroundService() 然后没有调用 Service.startForeground()

如何解决颤振音频服务 ?? android.app.RemoteServiceException: Context.startForegroundService() 然后没有调用 Service.startForeground()

在 Flutter 中,我使用 audio_service(Android/IOS) 插件在后台播放音频。

当我在后台显示的通知中单击 pause 、 play 或任何按钮时,该服务会引发以下错误。 这有什么问题吗?

pubspec.yaml 文件包括:

audio_session: ^0.0.10 
just_audio: ^0.6.9 
audio_service: ^0.16.2    
rxdart: ^0.24.1

================================================ ==========================

我在我的 androidManifest.xml 中添加以下标签

<uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<service android:name="com.ryanheise.audioservice.AudioService">
            <intent-filter>
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
        </service>

        <receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.MEDIA_BUTTON" />
            </intent-filter>
        </receiver>

然后在我的班级中,我用这个指令调用我的播放器班

 Container(
        child: AudioServiceWidget(child:Player()),width: MediaQuery.of(context).size.width,)

我的播放器类包含此处列出的相同代码,但不同之处在于它在我的树小部件中,而不是在如下示例中的主要部件中: https://pub.dev/packages/audio_service/example

import 'dart:async';
    import 'dart:io';
    import 'dart:math';
    import 'package:audio_service/audio_service.dart';
    import 'package:audio_session/audio_session.dart';
    import 'package:flutter/foundation.dart';
    import 'package:flutter/material.dart';
    import 'package:just_audio/just_audio.dart';
    import 'package:rxdart/rxdart.dart';
    
    class Player extends StatelessWidget  {
    @override
    Widget build(BuildContext context) {
    return Scaffold(
    body: Center(
    child: StreamBuilder<bool>(
    stream: AudioService.runningStream,builder: (context,snapshot) {
                           ...........................
                           .............................
    } } }

    

现在,当我使用我的应用程序时,播放器可以工作,但是当我单击通知栏上方的按钮时,应用程序崩溃并出现以下错误。

亚行日志:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.flutter_app1,PID: 10992
    android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground()
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1793)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6524)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)

ADB LOG 把 AndroidServiceWidget 直接放到我的班级之后。播放器运行正常,但单击播放器通知栏中的按钮后应用程序崩溃:

021-02-18 16:01:12.980 28652-28652/com.example.flutter_app1 D/MediaBrowserCompat: Connecting to a MediaBrowserService.
2021-02-18 16:01:13.024 28652-28652/com.example.flutter_app1 W/MediaButtonReceiver: More than one BroadcastReceiver that handles android.intent.action.MEDIA_BUTTON was found,returning null.
2021-02-18 16:01:13.024 28652-28652/com.example.flutter_app1 W/MediaSessionCompat: Couldn't find a unique registered media button receiver in the given context.
2021-02-18 16:01:20.249 28652-28659/com.example.flutter_app1 I/zygote: Do full code cache collection,code=125KB,data=111KB
2021-02-18 16:01:20.259 28652-28659/com.example.flutter_app1 I/zygote: After code cache collection,code=101KB,data=70KB
2021-02-18 16:01:20.313 28652-28652/com.example.flutter_app1 I/ExoPlayerImpl: Init 7e1bce [ExoPlayerLib/2.12.2] [TECNO-KA7-GO,TECNO KA7,TECNO MOBILE LIMITED,27]
2021-02-18 16:01:20.604 28652-28829/com.example.flutter_app1 I/System.out: isEmailSend:GET
2021-02-18 16:01:20.706 28652-28668/com.example.flutter_app1 I/zygote: Background concurrent copying GC freed 79822(6MB) AllocSpace objects,43(1144KB) LOS objects,79% free,2MB/11MB,paused 503us total 185.099ms
2021-02-18 16:01:20.799 28652-28829/com.example.flutter_app1 I/System.out: port:443
2021-02-18 16:01:20.876 28652-28652/com.example.flutter_app1 W/le.flutter_app1: type=1400 audit(0.0:8059): avc: denied { search } for name="clients" dev="debugfs" ino=7420 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:debugfs_ion:s0 tclass=dir permissive=0
2021-02-18 16:01:20.879 28652-28652/com.example.flutter_app1 D/skia: SkJpegCodec::onGetPixels + 
2021-02-18 16:01:21.071 28652-28652/com.example.flutter_app1 D/skia: SkJpegCodec::onGetPixels -
2021-02-18 16:01:21.521 28652-28668/com.example.flutter_app1 I/zygote: NativeAlloc concurrent copying GC freed 4664(306KB) AllocSpace objects,1(20KB) LOS objects,paused 214us total 177.472ms
2021-02-18 16:01:21.787 28652-28829/com.example.flutter_app1 I/System.out: [OkHttp] sendRequest>>
2021-02-18 16:01:21.789 28652-28829/com.example.flutter_app1 I/System.out: [OkHttp] sendRequest<<
2021-02-18 16:01:22.290 28652-28828/com.example.flutter_app1 W/AudioCapabilities: Unsupported mime audio/x-adpcm-ms
2021-02-18 16:01:22.292 28652-28828/com.example.flutter_app1 W/AudioCapabilities: Unsupported mime audio/x-adpcm-dvi-ima
2021-02-18 16:01:22.295 28652-28828/com.example.flutter_app1 W/AudioCapabilities: Unsupported mime audio/alac
2021-02-18 16:01:22.303 28652-28828/com.example.flutter_app1 W/AudioCapabilities: Unsupported mime audio/ape
2021-02-18 16:01:22.382 28652-28828/com.example.flutter_app1 W/VideoCapabilities: Unsupported mime video/divx
2021-02-18 16:01:22.421 28652-28828/com.example.flutter_app1 W/VideoCapabilities: Unrecognized profile/level 1/32 for video/mp4v-es
2021-02-18 16:01:22.421 28652-28828/com.example.flutter_app1 W/VideoCapabilities: Unrecognized profile/level 32768/2 for video/mp4v-es
2021-02-18 16:01:22.421 28652-28828/com.example.flutter_app1 W/VideoCapabilities: Unrecognized profile/level 32768/64 for video/mp4v-es
2021-02-18 16:01:22.436 28652-28828/com.example.flutter_app1 W/VideoCapabilities: Unsupported mime video/flv1
2021-02-18 16:01:22.475 28652-28828/com.example.flutter_app1 W/VideoCapabilities: Unsupported mime video/x-ms-wmv
2021-02-18 16:01:22.482 28652-28828/com.example.flutter_app1 W/VideoCapabilities: Unsupported mime video/xvid
2021-02-18 16:01:22.520 28652-28828/com.example.flutter_app1 W/VideoCapabilities: Unrecognized profile/level 1/32 for video/mp4v-es
2021-02-18 16:01:22.527 28652-28828/com.example.flutter_app1 I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
2021-02-18 16:01:22.859 28652-28834/com.example.flutter_app1 I/OMXClient: Treble IOmx obtained
2021-02-18 16:01:22.899 28652-28834/com.example.flutter_app1 I/ACodec: codec does not support config priority (err -2147483648)
2021-02-18 16:01:23.011 28652-28828/com.example.flutter_app1 D/AudioTrack: Client defaulted notificationFrames to 3675 for frameCount 11025
2021-02-18 16:01:23.242 28652-28659/com.example.flutter_app1 I/zygote: Do partial code cache collection,code=122KB,data=99KB
2021-02-18 16:01:23.278 28652-28659/com.example.flutter_app1 I/zygote: After code cache collection,data=99KB
2021-02-18 16:01:23.278 28652-28659/com.example.flutter_app1 I/zygote: Increasing code cache capacity to 512KB
2021-02-18 16:01:29.662 28652-28828/com.example.flutter_app1 D/AudioTrack: correcting timestamp time for pause,currentTimeNanos: 69361597167560 < limitNs: 69367023999339 < mStartNs: 69367075999339
2021-02-18 16:01:29.681 28652-28828/com.example.flutter_app1 D/AudioTrack: correcting timestamp time for pause,currentTimeNanos: 69361597167560 < limitNs: 69367023999339 < mStartNs: 69367075999339
2021-02-18 16:01:29.691 28652-28828/com.example.flutter_app1 D/AudioTrack: correcting timestamp time for pause,currentTimeNanos: 69361597167560 < limitNs: 69367023999339 < mStartNs: 69367075999339
2021-02-18 16:01:29.701 28652-28828/com.example.flutter_app1 D/AudioTrack: correcting timestamp time for pause,currentTimeNanos: 69361597167560 < limitNs: 69367023999339 < mStartNs: 69367075999339
2021-02-18 16:01:29.711 28652-28828/com.example.flutter_app1 I/chatty: uid=10467(com.example.flutter_app1) ExoPlayer:Playb identical 1 line
2021-02-18 16:01:29.721 28652-28828/com.example.flutter_app1 D/AudioTrack: correcting timestamp time for pause,currentTimeNanos: 69361597167560 < limitNs: 69367023999339 < mStartNs: 69367075999339
2021-02-18 16:01:29.732 28652-28828/com.example.flutter_app1 D/AudioTrack: correcting timestamp time for pause,currentTimeNanos: 69361597167560 < limitNs: 69367023999339 < mStartNs: 69367075999339
2021-02-18 16:01:29.742 28652-28828/com.example.flutter_app1 D/AudioTrack: correcting timestamp time for pause,currentTimeNanos: 69361597167560 < limitNs: 69367023999339 < mStartNs: 69367075999339
2021-02-18 16:01:36.585 28652-28668/com.example.flutter_app1 I/zygote: Background concurrent copying GC freed 29851(1403KB) AllocSpace objects,7(324KB) LOS objects,70% free,3MB/12MB,paused 596us total 101.321ms
2021-02-18 16:01:55.133 28652-28652/com.example.flutter_app1 D/AndroidRuntime: Shutting down VM
2021-02-18 16:01:55.152 28652-28652/com.example.flutter_app1 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.flutter_app1,PID: 28652
    android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground()
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1793)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6524)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res