Hi, I m receiving errors while building project for android devices. I searched for the solution but no idea about it. any idea?
/Users/bilalsimsek/Desktop/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.1.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:10: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
/Users/bilalsimsek/Desktop/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.1.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:11: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
^
/Users/bilalsimsek/Desktop/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.1.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:127: error: cannot find symbol
return PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(activity, permission);
^
symbol: variable ContextCompat
location: class FilePickerPlugin
/Users/bilalsimsek/Desktop/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.1.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:135: error: cannot find symbol
ActivityCompat.requestPermissions(activity, perm, PERM_CODE);
^
symbol: variable ActivityCompat
location: class FilePickerPlugin
It seems that it can't find the plugin somehow.
Run flutter clean and then flutter build apk if it doesn't work post your logs.
hi, thank you for your concern, I did exactly what you said. It runs on ios without problem but not on android. here are the logs.
`flutter build apk
Initializing gradle... 1,3s
Resolving dependencies... 4,0s
Gradle task 'assembleRelease'...
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)
/Users/bilalsimsek/Desktop/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.1.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:10: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
/Users/bilalsimsek/Desktop/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.1.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:11: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
^
/Users/bilalsimsek/Desktop/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.1.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:127: error: cannot find symbol
return PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(activity, permission);
^
symbol: variable ContextCompat
location: class FilePickerPlugin
/Users/bilalsimsek/Desktop/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.1.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:135: error: cannot find symbol
ActivityCompat.requestPermissions(activity, perm, PERM_CODE);
^
symbol: variable ActivityCompat
location: class FilePickerPlugin
4 errors
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':file_picker:compileReleaseJavaWithJavac'.
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
BU陌LD FAILED in 43s
44,2s
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1.`
Here is the flutter doctor results
`flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[鉁揮 Flutter (Channel beta, v1.0.0, on Mac OS X 10.14.2 18C54, locale tr-TR)
[鉁揮 Android toolchain - develop for Android devices (Android SDK 28.0.3)
[鉁揮 iOS toolchain - develop for iOS devices (Xcode 10.1)
[鉁揮 Android Studio (version 3.3)
[鉁揮 IntelliJ IDEA Ultimate Edition (version 2018.3.3)
[鉁揮 IntelliJ IDEA Community Edition (version 2018.3.3)
[鉁揮 VS Code (version 1.30.2)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
Process finished with exit code 0.`
What鈥檚 the minimum and target version of your app build.gradle?
Dear Miguel,
Problem occurs when I set true likeandroid.enableJetifier=true in gradle.properties because firebase_messaging 2.2.0 requires that. if I remove this and set firebase_messaging 2.1.0 I can successfully build the apk. it is ok for me for me to use these versions but for future I thing this problem should resolve. I m using target version 28.
I really thankfull for your effort.
Would you mind to try the beta branch and see if it still happens?
Replace your file picker dependency in the pubspec.yaml with:
file_picker:
git:
url: https://github.com/miguelpruivo/plugins_flutter_file_picker.git
ref: beta
@xyzbilal is this still happening with the solution provided?
@miguelpruivo i was having exactly the same problem. a Flutter upgrade forced me to target sdk 28 and to set the android.enableJetifier=true in order for Firestore packages to work. your git beta solved the errors above (after i installed image_picker_modern) but i can't yet confirm that everything works because now image_cropper is broken.
and i should note iOS builds now fail too, with:
[!] No podspec found forimage_picker_modernin.symlinks/plugins/image_picker_modern/ios``
i can't tell if that's a result of the image_picker_modern package itself or whether it's missing from the beta git branch.
@xyzbilal is this still happening with the solution provided?
I'm sorry I was focused to finish a project. in couple of days I will try it.
Hey,
I would like you to know that I was facing the same problem but after trying the beta branch the error disappeared. However, now image_picker_modern is broken.
possible to use image_picker as the dependency and not image_picker_modern? the former has already handled the androidX migration:
https://pub.dartlang.org/packages/image_picker#-changelog-tab-
@blaneyneil @Hussain-AlBayyat I just reverted it back to image_picker back again on beta.
Could you clean your project and see if it is working now? Thank you.
i removed my .pub-cache and ran packages get again, cleaned, and still got this trying to build android:
The following Dart file:
/Users/neil/flutter/.pub-cache/git/plugins_flutter_file_picker-ad71c0d940e2ed271f8f1ee6c5680bd72351df33/lib/file_picker.dart
...refers, in an import, to the following library:
package:image_picker_modern/image_picker_modern.dart
That library is in a package that is not known. Maybe you forgot to mention it in your pubspec.yaml file?
It is working now, thank you.
yes, this is working. thanks much. the git repo was cached so kept pulling in the old beta. and then another package broke because of androidX...
Good to know, I'll try to update master and Dart pub with this (and probably a few other) updates when I have sometime.
Leaving this issue open as of now so others can see it.
Works nicely thank you for your effort.
Version 1.2.0 is now out on master and Dart Pub. You can use it with file_picker: ^1.2.0.