简体   繁体   中英

Flutter file_picker plugin can't build project

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>

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>

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.

像这样的文件名。

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

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.** { *; } -keep class androidx.lifecycle.** { *; }

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

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

``

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM