Flutter file_picker plugin can't build project

2,105

Solution 1

Because file_picker currently doesn't support scoped storage, you'll need to set android:requestLegacyExternalStorage="true" on your AndroidManifest.xml file, under :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.app.www.app">
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="finosellapp"
        android:requestLegacyExternalStorage="true"
        android:icon="@mipmap/ic_launcher">
       
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">

            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme"
                />

            <meta-data
                android:name="io.flutter.embedding.android.SplashScreenDrawable"
                android:resource="@drawable/launch_background"
                />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

Solution 2

Add this one to your Android Manifest file

android:requestLegacyExternalStorage="true" 

And Change app compileSdkVersion to 28 in filepicker build.gradle file. To get this file you requested to open MainActivity.class file in andriod folder at right corner Open for Editing android studio click on that it open as new android project. then select file filepicker build.gradle file.

Hope this will help to you.

File Name like this.

I struggle with this issue past 5days, now only I fixed.

Share:
2,105
Moses Adeyinka
Author by

Moses Adeyinka

Updated on December 24, 2022

Comments

  • Moses Adeyinka
    Moses Adeyinka over 1 year

    After adding file_picker: ^1.13.3 to my dependencies the project can't build with this error

    FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':app:mergeDebugJavaResource'.

    A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade File 'com.android.builder.files.ZipCentralDirectory@7dfb72cd' was deleted, but previous version not found in cache

    • 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 8s Exception: Gradle task assembleDebug failed with exit code 1

    but each time i remove it the project builds successfully, please help out i have tried various versions suggested but all to no avail

    Here is the android manifest as requested

     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.app.www.app">
       <application
            android:name="io.flutter.app.FlutterApplication"
            android:label="finosellapp"
            android:icon="@mipmap/ic_launcher">
            <activity
                android:name=".MainActivity"
                android:launchMode="singleTop"
                android:theme="@style/LaunchTheme"
                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
                android:hardwareAccelerated="true"
                android:windowSoftInputMode="adjustResize">
              
                <meta-data
                  android:name="io.flutter.embedding.android.NormalTheme"
                  android:resource="@style/NormalTheme"
                  />
              
                <meta-data
                  android:name="io.flutter.embedding.android.SplashScreenDrawable"
                  android:resource="@drawable/launch_background"
                  />
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
            </activity>
            <meta-data
                android:name="flutterEmbedding"
                android:value="2" />
        </application>
    </manifest>
    
  • Amon C
    Amon C over 3 years
    If it works then please set it as a correct answer. It will help other developers too.
  • Amon C
    Amon C over 3 years
    What's you issue? @LizardKing_96
  • LizardKingLK
    LizardKingLK over 3 years
    The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility. Building plugin file_picker...
  • LizardKingLK
    LizardKingLK over 3 years
    I followed the instructions given by the issues page and it did not help. flutter.dev/docs/development/androidx-migration
  • Amon C
    Amon C over 3 years
    That could be another case. There are different settings when you use AndroidX and when not. Ask a question and comment here I will try to help.