针对image_picker_saver错误的AndroidX不兼容错误

时间:2019-05-14 08:40:04

标签: image flutter androidx

在运行控制台期间,image_picker_saver软件包使AndroidX不兼容。 包裹是-image_picker_saver:^ 0.1.0

任何人都可以帮助解决该错误吗?

运行控制台-

                                   ^
      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.

2 个答案:

答案 0 :(得分:0)

我建议您启用AndroidX。

官方文档:https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility

如您在第三项中所见:

在android / gradle.properties中,附加=>

android.enableJetifier=true
android.useAndroidX=true

如果您不想使用AndroidX,则可以使用下面列出的最新版本的软件包。

如果您的软件包未在此处列出,则只能选择启用AndroidX。

还要在android / app / gradle.build中更改最小sdk:

    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"
    }

最后,遵循该答案:

How to fix "Execution failed for task ':app:processDebugResources'. > Android resource linking failed"[Android/Flutter]

也更改gradle版本。

答案 1 :(得分:0)

image_picker_saver hava已升级至0.3.0,并支持Android X