Why This Happens
In Flutter, PlatformException is thrown when native code on Android or iOS encounters an error during a platform channel call. Common causes include missing permissions, unavailable hardware features, or incorrect native configuration.
The Problem
// Requesting camera without permission in AndroidManifest.xml
final image = await ImagePicker().pickImage(source: ImageSource.camera);The Fix
// 1. Add to AndroidManifest.xml:
// <uses-permission android:name="android.permission.CAMERA"/>
// 2. Request permission at runtime:
final status = await Permission.camera.request();
if (status.isGranted) {
final image = await ImagePicker().pickImage(source: ImageSource.camera);
}Step-by-Step Fix
- 1
Identify the error
Look at the PlatformException details including the error code and message to understand which native operation failed.
- 2
Find the cause
Check if required permissions are declared in AndroidManifest.xml or Info.plist, and if runtime permissions have been requested.
- 3
Apply the fix
Add the required platform permissions and implement runtime permission requests before calling the native feature.
Got the actual stack trace?
Paste it into our free AI explainer to get the cause and the fix for your specific case — no signup, nothing to install.
Explain my errorBugsly catches this automatically
Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.
Try Bugsly free