4

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>

3 Answers3

4

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>
Amon C
  • 1,710
  • 9
  • 17
  • If it works then please set it as a correct answer. It will help other developers too. – Amon C Sep 07 '20 at 11:51
  • What's you issue? @LizardKing_96 – Amon C Nov 16 '20 at 07:31
  • 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 Nov 16 '20 at 08:03
  • I followed the instructions given by the issues page and it did not help. https://flutter.dev/docs/development/androidx-migration – LizardKingLK Nov 16 '20 at 08:04
  • 1
    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. – Amon C Nov 16 '20 at 13:00
1

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.

JideGuru
  • 7,102
  • 6
  • 26
  • 48
0

ADD: android:requestLegacyExternalStorage="true" in your AndroidManifest.xml

ADD: classpath 'com.android.tools.build:gradle:3.6.3' in your android -> build.gradle

ebuildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
    }
}

ADD: distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip in your gradle-wrapper.properties

Create a file 'proguard-rules.pro' and write: -keep class androidx.lifecycle.** { *; }

In your android -> app -> build.gradle add:

android{
    buildTypes {
       release{
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
    }
}

``