flutter
flutter copied to clipboard
On my Android (Galaxy S10) not opening the camera or gallery
Is there an existing issue for this?
- [X] I have searched the existing issues
- [X] I have read the guide to filing a bug
Steps to reproduce
If I follow the steps below on my Android device nothing happens while on my iOS device everything works fine. This is exactly the same behaviour as when we load one of or partner their web views into our app.
- Clone the flutter_webview_issue repo
- Run the app on your device
- Tap on either the gallery or camera button
Expected results
For the web view to open either the gallery or the camera based on the button you've pressed.
Actual results
Nothing happens.
Code sample
Source from our flutter_webview_issue repo.
Code sample
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: WebViewContainer(),
debugShowCheckedModeBanner: false,
);
}
}
class WebViewContainer extends StatefulWidget {
const WebViewContainer({super.key});
@override
State<WebViewContainer> createState() => _WebViewContainerState();
}
class _WebViewContainerState extends State<WebViewContainer> {
final _url =
'https://6495ac7394575140f22df7b5--react-native-photo-gallery-apis.netlify.app/';
WebViewController? webViewController;
@override
void initState() {
[
Permission.photos,
Permission.camera,
Permission.mediaLibrary,
Permission.videos,
].request().then((value) {
webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..loadRequest(Uri.parse(_url));
setState(() {});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('WebView')),
body: webViewController != null
? WebViewWidget(
controller: webViewController!,
)
: const Center(child: CircularProgressIndicator()),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.10.4, on macOS 13.3.1 22E772610a darwin-arm64, locale en-GB)
• Flutter version 3.10.4 on channel stable at /Users/jopmiddelkamp/fvm/versions/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 682aa387cf (3 weeks ago), 2023-06-05 18:04:56 -0500
• Engine revision 2a3401c9bb
• Dart version 3.0.3
• DevTools version 2.23.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/jopmiddelkamp/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Users/jopmiddelkamp/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9514443/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.12.1
[✓] Android Studio (version 2022.1)
• Android Studio at /Users/jopmiddelkamp/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9514443/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
[✓] Android Studio (version 2022.1)
• Android Studio at /Users/jopmiddelkamp/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9619390/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
[✓] VS Code (version 1.79.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.66.0
[✓] Connected device (2 available)
• SM G973F (mobile) • R58N94GTXNE • android-arm64 • Android 12 (API 31)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.3.1 22E772610a darwin-arm64
[✓] Network resources
• All expected network resources are available.
• No issues found!
Thanks for the report @jopmiddelkamp Although I don't have the specific device to verify, but I tried on Samsung A2Core device on which the camera and gallery opens properly. Can you provide a short video of the behavior ? Is there any permission or setting on the phone that might be preventing it to open ?
@darshankawar
Video: https://github.com/flutter/flutter/assets/1774351/a623cb24-4e57-4c42-9ab8-9be23097e601
Screenshot of permissions:
Thanks for the update. I am getting same behavior upon running the code sample on Pixel emulator and tapping on buttons shows me below in console:
E/FrameEvents( 4347): updateAcquireFence: Did not find frame.
E/FrameEvents( 4347): updateAcquireFence: Did not find frame.
E/FrameEvents( 4347): updateAcquireFence: Did not find frame.
E/FrameEvents( 4347): updateAcquireFence: Did not find frame.
E/FrameEvents( 4347): updateAcquireFence: Did not find frame.
Does it work on any other Android device apart from S10 ?
Not not yet. I normally test the app on physical devices. I do also have a Galaxy S6 and Xiaomi Redmi device which I havent tried yet. Would you like me to test it on these devices as well?
Would you like me to test it on these devices as well?
Yes please. Also, looking at the code sample provided, you seem to be trying to open the device's camera or gallery that is wrapped in a webview. So in this case, maybe you can also try to run the image_picker package example clubbing it with webview code implementation and see if using it, you still get same behavior or not on S10.
Tried it on all these devices and non of them are working for me it all gives the same result. I tap one of the buttons but nothing happens.
Galaxy S10 Android version: 12
Galaxy S6 Android version: 7
Pixel 4 Android version: 13
Redmi Note 8T Android version: 10
Android simulator Android version: 13 sdk_gphone64_arm64
Thanks for the update @jopmiddelkamp Can you take a look at this fix and see if it helps in your case ?
@darshankawar this seems to solve the problem indeed. Thanks for your help!
Good to know.Closing as resolved.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v
and a minimal reproduction of the issue.