所用 Package :permission_handler: ^10.0.0
应用程序/构建版本.Gradle
compileSdkVersion 33
minSdkVersion 24
targetSdkVersion 33
安卓系统/内部版本.gradle
kotlin_version = '1.7.10'
在AndroidManifest.xml中添加权限
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.CAMERA" />
单击允许或拒绝权限时崩溃日志
E/AndroidRuntime(13312): FATAL EXCEPTION: main
E/AndroidRuntime(13312): Process: com.app.example, PID: 13312
E/AndroidRuntime(13312): java.lang.AssertionError
E/AndroidRuntime(13312): at io.flutter.plugins.firebase.messaging.FlutterFirebasePermissionManager.onRequestPermissionsResult(FlutterFirebasePermissionManager.java:33)
E/AndroidRuntime(13312): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onRequestPermissionsResult(FlutterEngineConnectionRegistry.java:777)
E/AndroidRuntime(13312): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onRequestPermissionsResult(FlutterEngineConnectionRegistry.java:409)
E/AndroidRuntime(13312): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onRequestPermissionsResult(FlutterActivityAndFragmentDelegate.java:757)
E/AndroidRuntime(13312): at io.flutter.embedding.android.FlutterFragment.onRequestPermissionsResult(FlutterFragment.java:915)
E/AndroidRuntime(13312): at io.flutter.embedding.android.FlutterFragmentActivity.onRequestPermissionsResult(FlutterFragmentActivity.java:549)
E/AndroidRuntime(13312): at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8833)
E/AndroidRuntime(13312): at android.app.Activity.dispatchActivityResult(Activity.java:8663)
E/AndroidRuntime(13312): at android.app.ActivityThread.deliverResults(ActivityThread.java:5857)
E/AndroidRuntime(13312): at android.app.ActivityThread.handleSendResult(ActivityThread.java:5903)
E/AndroidRuntime(13312): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:54)
E/AndroidRuntime(13312): at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
E/AndroidRuntime(13312): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(13312): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(13312): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2438)
E/AndroidRuntime(13312): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(13312): at android.os.Looper.loopOnce(Looper.java:226)
E/AndroidRuntime(13312): at android.os.Looper.loop(Looper.java:313)
E/AndroidRuntime(13312): at android.app.ActivityThread.main(ActivityThread.java:8663)
E/AndroidRuntime(13312): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(13312): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
E/AndroidRuntime(13312): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
I/Process (13312): Sending signal. PID: 13312 SIG: 9
权限请求代码
Future<PermissionStatus> requestStoragePermission() async {
return Platform.isAndroid ? Permission.storage.request() : Permission.photos.request();
}
3条答案
按热度按时间mhd8tkvw1#
此问题是由firebase_messaging引起的:13.0.0
升级所有与firebase相关的软件包将解决此权限崩溃问题。
已在Github中关闭的问题:
https://github.com/firebase/flutterfire/issues/9430https://github.com/firebase/flutterfire/issues/9429
dxxyhpgq2#
在我这边,这个问题是由使用
firebase_messaging: ^13.0.0
请求通知权限引起的升级到
firebase_messaging: ^13.1.0
后,应用程序停止并崩溃nhn9ugyo3#
https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions
我也遇到了同样的问题。我相信这是
READ_EXTERNAL_STORAGE
在Android 13上不再是有效权限的情况。我试图请求存储权限,它像你提到的那样崩溃了。但是,我相信我们的应用程序需要支持比Android 13更早的版本。我们应该如何正确处理旧版本(需要存储权限)与新的Android 13版本(不需要/支持存储权限)。