简体   繁体   English

Flutter file_picker 插件无法构建项目

[英]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将 file_picker: ^1.13.3 添加到我的依赖项后,项目无法构建并出现此错误

FAILURE: Build failed with an exception. FAILURE:构建失败,出现异常。

  • What went wrong: Execution failed for task ':app:mergeDebugJavaResource'.出了什么问题:任务 ':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执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade 文件 'com.android.builder.files.ZipCentralDirectory@7dfb72cd' 时发生失败,但在缓存中找不到以前的版本

  • Try: Run with --stacktrace option to get the stack trace.尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。 Run with --info or --debug option to get more log output.使用 --info 或 --debug 选项运行以获得更多日志输出。 Run with --scan to get full insights.使用 --scan 运行以获得完整的见解。

  • Get more help at https://help.gradle.orghttps://help.gradle.org获取更多帮助

BUILD FAILED in 1m 8s Exception: Gradle task assembleDebug failed with exit code 1 BUILD FAILED in 1m 8s 异常:Gradle 任务 assembleDebug 失败,退出代码为 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这是请求的android清单

 <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 :由于 file_picker 当前不支持范围存储,您需要在 AndroidManifest.xml 文件中设置android:requestLegacyExternalStorage="true" ,位于:

<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 清单文件中

android:requestLegacyExternalStorage="true" 

And Change app compileSdkVersion to 28 in filepicker build.gradle file.并在 filepicker build.gradle文件中将 app compileSdkVersion更改为 28。 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.要获取此文件,您要求在右上角的 andriod 文件夹中打开MainActivity.class文件 Open for Editing android studio 单击它作为新的 android 项目打开。 then select file filepicker build.gradle file.然后选择文件 filepicker build.gradle文件。

Hope this will help to you.希望这会对你有所帮助。

像这样的文件名。

I struggle with this issue past 5days, now only I fixed.过去 5 天我一直在努力解决这个问题,现在只有我解决了。

ADD: android:requestLegacyExternalStorage="true" in your AndroidManifest.xml添加:android:requestLegacyExternalStorage="true" 在你的 AndroidManifest.xml

ADD: classpath 'com.android.tools.build:gradle:3.6.3' in your android -> build.gradle添加:类路径 'com.android.tools.build:gradle:3.6.3' 在你的 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在您的 gradle-wrapper.properties 中添加: distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip

Create a file 'proguard-rules.pro' and write: -keep class androidx.lifecycle.** { *; }创建一个文件“proguard-rules.pro”并写入: -keep class androidx.lifecycle.** { *; } -keep class androidx.lifecycle.** { *; }

In your android -> app -> build.gradle add:在你的 android -> app -> build.gradle 添加:

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

`` ``

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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