三星手机中的 Flutter 构建失败,权限被拒绝:来自 android 的广播要求以用户 -1 的身份运行,但从用户 0 调用
Posted
技术标签:
【中文标题】三星手机中的 Flutter 构建失败,权限被拒绝:来自 android 的广播要求以用户 -1 的身份运行,但从用户 0 调用【英文标题】:Flutter build fails in Samsung phone , Permission Denial: broadcast from android asks to run as user -1 but is calling from user 0 【发布时间】:2021-10-30 16:38:09 【问题描述】:尝试在三星 Note 8 手机上构建以前工作的应用程序,这是错误Permission Denial: broadcast from android asks to run as user -1 but is calling from user 0
不适用于三星 Note 8,android 版本 9 在小米 A3 上工作,Android 版本 11现在我了解只有访问系统功能的系统应用程序才需要 INTERACT_ACROSS_USERS_FULL 权限。我的这个应用程序之前运行正常,升级了flutter和dart版本,还升级了Mobile OS。
即使在所有清单文件中添加了这些权限,仍然无法正常工作,
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
也试过这个,甚至通过调整手机上的开发人员选项来工作一次,因为我在这里回答tweaking developer options,但现在这也行不通。
这是我的扑医生,
[✓] Flutter (Channel master, 2.6.0-1.0.pre.153, on macOS 11.5.1 20G80 darwin-x64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for ios and macOS (Xcode 12.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Connected device (2 available)
而Full错误是这样的,
D/vndksupport( 5675): Loading /vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
E/flutter ( 5675): [ERROR:flutter/fml/platform/android/jni_util.cc(182)] java.lang.SecurityException: Permission Denial: broadcast from android asks to run as user -1 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERACT_ACROSS_USERS
E/flutter ( 5675): at android.os.Parcel.createException(Parcel.java:1966)
E/flutter ( 5675): at android.os.Parcel.readException(Parcel.java:1934)
E/flutter ( 5675): at android.os.Parcel.readException(Parcel.java:1884)
E/flutter ( 5675): at android.app.IActivityManager$Stub$Proxy.reportActivityFullyDrawn(IActivityManager.java:7312)
E/flutter ( 5675): at android.app.Activity.reportFullyDrawn(Activity.java:2092)
E/flutter ( 5675): at io.flutter.embedding.android.FlutterActivity.onFlutterUiDisplayed(FlutterActivity.java:1100)
E/flutter ( 5675): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate$1.onFlutterUiDisplayed(FlutterActivityAndFragmentDelegate.java:88)
E/flutter ( 5675): at io.flutter.embedding.android.FlutterView$2.onFlutterUiDisplayed(FlutterView.java:133)
E/flutter ( 5675): at io.flutter.embedding.engine.FlutterJNI.onFirstFrame(FlutterJNI.java:462)
E/flutter ( 5675): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 5675): at android.os.MessageQueue.next(MessageQueue.java:326)
E/flutter ( 5675): at android.os.Looper.loop(Looper.java:181)
E/flutter ( 5675): at android.app.ActivityThread.main(ActivityThread.java:7073)
E/flutter ( 5675): at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 5675): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/flutter ( 5675): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
E/flutter ( 5675): Caused by: android.os.RemoteException: Remote stack trace:
E/flutter ( 5675): at com.android.server.am.UserController.handleIncomingUser(UserController.java:1818)
E/flutter ( 5675): at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:25789)
E/flutter ( 5675): at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:25720)
E/flutter ( 5675): at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:26590)
E/flutter ( 5675): at android.app.ContextImpl.sendBroadcastAsUser(ContextImpl.java:1264)
E/flutter ( 5675):
E/flutter ( 5675):
F/flutter ( 5675): [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1220)] Check failed: fml::jni::CheckException(env).
F/libc ( 5675): Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 5675 (bro.neighbroapp), pid 5675 (bro.neighbroapp)
【问题讨论】:
在将旧插件更新到 v2 后也遇到了这个问题。你找到解决办法了吗? 与 Galaxy S7 / Android 8 相同的问题。昨天工作,今天停止工作。我不知道是什么原因造成的。我的其他测试设备 Galaxy A52 / Android 11 没有问题。 【参考方案1】:这是 Flutter 最新版本的问题,我用下面的 eidt 修复了它,
这是一种解决方法,它对我有用。
-
转至
MainActivity.kt
导入 import android.os.Build
粘贴这个
override fun onFlutterUiDisplayed()
if (Build.VERSION.SDK_INT >= 100) //I gave 100 just to confirm , it shoud be android ver 10
reportFullyDrawn();
flutter clean
flutter run
【讨论】:
我通过将<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background"/>
恢复到 AndroidManifest.xml 来解决此问题。根据最新的 Flutter 指南,我之前已将其删除。
这对我有用。感谢您发布!疯了,这是需要的。您是如何得知此解决方案的?
这对我不起作用。看起来也很老套。
恢复<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background"/>
确实有效。但它确实会导致从初始启动画面到 SlapshscreenDrawable 的淡入淡出/闪烁,但它可以防止崩溃:-)
@TjerkW 你找到闪烁的解决方案了吗?以上是关于三星手机中的 Flutter 构建失败,权限被拒绝:来自 android 的广播要求以用户 -1 的身份运行,但从用户 0 调用的主要内容,如果未能解决你的问题,请参考以下文章