Issue
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>
Solution
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>
Answered By – Amon Chowdhury
Answer Checked By – Mary Flores (FlutterFixes Volunteer)