问题
During the run console, the image_picker_saver package is giving AndroidX incompability. the package is - image_picker_saver: ^0.1.0
Can anyone help how to handle this error?
Run console -
^
symbol: variable ActivityCompat
C:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker_saver-0.1.0\android\src\main\java\io\flutter\plugins\imagepickersaver\ImagePickerDelegate.java:139: error: cannot find symbol
ActivityCompat.requestPermissions(activity, new String[]{permissionName}, requestCode);
^
symbol: variable ActivityCompat
C:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker_saver-0.1.0\android\src\main\java\io\flutter\plugins\imagepickersaver\ImagePickerDelegate.java:151: 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_saver: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 1m 36s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
回答1:
I suggest you to enable AndroidX.
Official docs: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
As you see in third entry:
In android/gradle.properties, append =>
android.enableJetifier=true
android.useAndroidX=true
If you don't want to use AndroidX, latest version of packages you can use listed down below.
If your package don't listed there, enabling AndroidX is only choice.
Also change your minimum sdk inside android/app/gradle.build:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_testing"
minSdkVersion 16 // => Make this 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
And finally, follow that answer:
How to fix "Execution failed for task ':app:processDebugResources'. > Android resource linking failed"[Android/Flutter]
Change the gradle version also.
回答2:
image_picker_saver hava upgraded to 0.3.0 and support Android X
来源:https://stackoverflow.com/questions/56126272/androidx-incompatibility-error-for-image-picker-saver-error