繁体   English   中英

Flutter file_picker 插件无法构建项目

[英]Flutter file_picker plugin can't build project

将 file_picker: ^1.13.3 添加到我的依赖项后,项目无法构建并出现此错误

FAILURE:构建失败,出现异常。

  • 出了什么问题:任务 ':app:mergeDebugJavaResource' 执行失败。

执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade 文件 'com.android.builder.files.ZipCentralDirectory@7dfb72cd' 时发生失败,但在缓存中找不到以前的版本

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获得更多日志输出。 使用 --scan 运行以获得完整的见解。

  • https://help.gradle.org获取更多帮助

BUILD FAILED in 1m 8s 异常:Gradle 任务 assembleDebug 失败,退出代码为 1

但是每次我删除它时,项目都会成功构建,请帮助我尝试了各种建议的版本,但都无济于事

这是请求的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>

由于 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>

将此添加到您的 Android 清单文件中

android:requestLegacyExternalStorage="true" 

并在 filepicker build.gradle文件中将 app compileSdkVersion更改为 28。 要获取此文件,您要求在右上角的 andriod 文件夹中打开MainActivity.class文件 Open for Editing android studio 单击它作为新的 android 项目打开。 然后选择文件 filepicker build.gradle文件。

希望这会对你有所帮助。

像这样的文件名。

过去 5 天我一直在努力解决这个问题,现在只有我解决了。

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

添加:类路径 'com.android.tools.build:gradle:3.6.3' 在你的 android -> build.gradle

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

在您的 gradle-wrapper.properties 中添加: distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip

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

在你的 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