Skip to content

java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider #66108

@b055man

Description

@b055man

[✓] Flutter: is fully installed. (Channel stable, 1.20.3, on Mac OS X 10.15.4 19E287, locale en-GB)
[✓] Android toolchain - develop for Android devices: is fully installed. (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS: is fully installed. (Xcode 11.4.1)
[✓] Android Studio: is fully installed. (version 3.6)
[✓] VS Code: is fully installed. (version 1.48.2)
[✓] Connected device: is fully installed. (2 available)

Steps to Reproduce

Looks to be related to the one logged here: #65388 but it has been closed already.

  1. Run flutter create bug.
  2. Update the files as follows:
  • main.dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController _controller;

  @override
  void initState() {
    _controller = TextEditingController();
    _controller.value = TextEditingValue(text: 'abc');
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextField(
              controller: _controller,
            ),
          ],
        ),
      ),
    );
  }
}

3. Build and run the app.

Expected results:
App starts without exceptions

Actual results:
App logs an exception

Logs: Immediately after starting the app, the following exception is logged:
W/ClipData(29672): Failure opening stream
W/ClipData(29672): java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/file/125 from pid=29672, uid=10307 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
W/ClipData(29672): 	at android.os.Parcel.createException(Parcel.java:1950)
W/ClipData(29672): 	at android.os.Parcel.readException(Parcel.java:1918)
W/ClipData(29672): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
W/ClipData(29672): 	at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:146)
W/ClipData(29672): 	at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:698)
W/ClipData(29672): 	at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1460)
W/ClipData(29672): 	at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1404)
W/ClipData(29672): 	at android.content.ClipData$Item.coerceToText(ClipData.java:351)
W/ClipData(29672): 	at io.flutter.plugin.platform.PlatformPlugin.getClipboardData(PlatformPlugin.java:278)
W/ClipData(29672): 	at io.flutter.plugin.platform.PlatformPlugin.access$700(PlatformPlugin.java:24)
W/ClipData(29672): 	at io.flutter.plugin.platform.PlatformPlugin$1.getClipboardData(PlatformPlugin.java:81)
W/ClipData(29672): 	at io.flutter.embedding.engine.systemchannels.PlatformChannel$1.onMethodCall(PlatformChannel.java:141)
W/ClipData(29672): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:230)
W/ClipData(29672): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
W/ClipData(29672): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
W/ClipData(29672): 	at android.os.MessageQueue.nativePollOnce(Native Method)
W/ClipData(29672): 	at android.os.MessageQueue.next(MessageQueue.java:326)
W/ClipData(29672): 	at android.os.Looper.loop(Looper.java:170)
W/ClipData(29672): 	at android.app.ActivityThread.main(ActivityThread.java:6991)
W/ClipData(29672): 	at java.lang.reflect.Method.invoke(Native Method)
W/ClipData(29672): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/ClipData(29672): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884)

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.platform-androidAndroid applications specifically

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions