Repository navigation
App crashes after adding image_picker plugin #24859
Copy link
Copy link
Closed
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolep: image_pickerThe Image Picker plugin.The Image Picker plugin.p: toolingAffects the flutter_plugin_tools packageAffects the flutter_plugin_tools packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyt: gradle"flutter build" and "flutter run" on Android"flutter build" and "flutter run" on AndroidtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Description
App crashes after adding image_picker plugin.
pubspec.yaml
dependencies:
image_picker: ^0.4.10
$ flutter doctor -v
[✓] Flutter (Channel beta, v0.11.12, on Linux, locale en_IN)
• Flutter version 0.11.12 at /home/bhanu/software/flutter
• Framework revision 06ec8d3b41 (15 hours ago), 2018-11-28 15:56:58 -0800
• Engine revision 72c7a75672
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /home/bhanu/software/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /home/bhanu/software/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] Android Studio (version 3.2)
• Android Studio at /home/bhanu/software/android-studio
• Flutter plugin version 30.0.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] IntelliJ IDEA Community Edition (version 2018.2)
• IntelliJ at /home/bhanu/software/idea-IC-182.4892.20
• Flutter plugin version 29.1.3
• Dart plugin version 182.4892.25
[✓] VS Code (version 1.29.1)
• VS Code at /usr/share/code
• Flutter extension version 2.21.0
[✓] Connected device (1 available)
• Redmi 3S • 0123456789ABCDEF • android-arm64 • Android 8.1.0 (API 27)
• No issues found!
flutter run
Launching lib/main.dart on Redmi 3S in debug mode...
Initializing gradle... 1.4s
Resolving dependencies... 3.2s
Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java:8: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
^
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:15: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
^
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:16: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:17: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
^
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerFileProvider.java:3: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
^
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerFileProvider.java:10: error: cannot find symbol
public class ImagePickerFileProvider extends FileProvider {}
^
symbol: class FileProvider
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java:40: error: cannot find symbol
@VisibleForTesting
^
symbol: class VisibleForTesting
location: class ImagePickerPlugin
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:68: error: cannot find symbol
@VisibleForTesting static final int REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY = 2342;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:69: error: cannot find symbol
@VisibleForTesting static final int REQUEST_CODE_TAKE_IMAGE_WITH_CAMERA = 2343;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:70: error: cannot find symbol
@VisibleForTesting static final int REQUEST_EXTERNAL_IMAGE_STORAGE_PERMISSION = 2344;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:71: error: cannot find symbol
@VisibleForTesting static final int REQUEST_CAMERA_IMAGE_PERMISSION = 2345;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:72: error: cannot find symbol
@VisibleForTesting static final int REQUEST_CODE_CHOOSE_VIDEO_FROM_GALLERY = 2352;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:73: error: cannot find symbol
@VisibleForTesting static final int REQUEST_CODE_TAKE_VIDEO_WITH_CAMERA = 2353;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:74: error: cannot find symbol
@VisibleForTesting static final int REQUEST_EXTERNAL_VIDEO_STORAGE_PERMISSION = 2354;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:75: error: cannot find symbol
@VisibleForTesting static final int REQUEST_CAMERA_VIDEO_PERMISSION = 2355;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:77: error: cannot find symbol
@VisibleForTesting final String fileProviderName;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:164: error: cannot find symbol
@VisibleForTesting
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:122: error: cannot find symbol
return ActivityCompat.checkSelfPermission(activity, permissionName)
^
symbol: variable ActivityCompat
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:128: error: cannot find symbol
ActivityCompat.requestPermissions(activity, new String[] {permissionName}, requestCode);
^
symbol: variable ActivityCompat
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:140: error: cannot find symbol
return FileProvider.getUriForFile(activity, fileProviderName, file);
^
symbol: variable FileProvider
20 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':image_picker:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 13s
Gradle task 'assembleDebug'... Done 14.3s
Gradle task assembleDebug failed with exit code 1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolep: image_pickerThe Image Picker plugin.The Image Picker plugin.p: toolingAffects the flutter_plugin_tools packageAffects the flutter_plugin_tools packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyt: gradle"flutter build" and "flutter run" on Android"flutter build" and "flutter run" on AndroidtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Activity
[-]App crashes after adding image severe: crash[/-][+]App crashes after adding image_picker plugin[/+]zoechi commentedon Nov 29, 2018
Please try deleting
/home/bhanu/software/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.10/and then runflutter packages getagain.bhanu-mantri commentedon Nov 30, 2018
That is not working, it is showing the same error.
zoechi commentedon Dec 4, 2018
#24201 (comment) might help
bhanu-mantri commentedon Dec 5, 2018
I already have
classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.google.gms:google-services:4.1.0'in my project level build.gradle, It is not working.zoechi commentedon Dec 5, 2018
@bhanu-manthry ensure you have
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zipinandroid/gradle/wrapper7gradle-wrapper.properties3 remaining items
iKK001 commentedon Feb 26, 2019
Same here ! I use AndroidX and the
image_pickerdependency makes again problems (I did an Android update today and afterwards nothing worked again with the image_picker dependency).I tried:
a) delete package, found here...
/Users/username/Projects/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1b) make sure I have the AndroidX-version of the image_picker inside pubspec.yaml (currently this is
image_picker: 0.4.12+1c) do
flutter packages getso that the package gets re-installed freshd) make a
flutter cleane) I open Android Studio and all the grade compilation is successful - however, opening the Flutter App in Android does still crash !
Something is still wrong. What else do I need to do in order to make
image_pickerwork again in AndroidX ????Here is the error message I get:
iKK001 commentedon Feb 26, 2019
I have found a solution:
In
gradle.propertiesset enableJetifier tofalse(i.e. only keep the first one totrue)...I have no idea why this was suddenly necessary today.
Any explanation highly appreciated. Thanks.
diazsasak commentedon Jun 10, 2019
i have same exact issue. and i resolved by updating pubspec.yaml:
from image_picker: ^0.4.10 to image_picker: ^0.6.0+9
maylortaylor commentedon Aug 2, 2019
I too am getting this same issue when trying to update my app to AndroidX.
If i have my app as non-AndroidX, it "works" but i get another issue of the selected image not appearing only when on actual device.
Here is a stackoverflow for my issue -- https://stackoverflow.com/questions/57316514/image-not-showing-on-phone-but-shows-on-emulator
NewITCorp commentedon Aug 24, 2019
Is this a good to go workaround?
csells commentedon Jan 13, 2020
@bhanu-manthry we've made a lot of improvements to our Gradle support, including for AndroidX. Can you test to see if this issue still occurs on 1.12?
iapicca commentedon Feb 13, 2020
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.
Could everyone who still has this problem please file a new issue with the exact descriptions what happens, logs and the output of 'flutter doctor -v' please.
All system setups can be slightly different so it's always better to open new issues and reference related issues.
shahzodjonweb commentedon Apr 6, 2021
Use image_picker: ^0.6.6+1 and add AndroidManifest.xml following:
<uses-permission android:name="android.permission.INTERNET"/>This way worked for me!
github-actions commentedon Aug 3, 2021
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 -vand a minimal reproduction of the issue.