错误:flutter中的downloads_path_provider。

最后发布: 2020-07-09


问题

我在使用 本包 在安卓系统中获取下载路径,效果很好,通过使用这个包,我得到了 /storage/emulated/0/Download 我想要的。

问题:当我运行 flutter run --release 它抛出一个错误。

Launching lib\main.dart on SM J700F in release mode...
Running Gradle task 'assembleRelease'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':downloads_path_provider:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\Sandeep Sharma\.gradle\caches\transforms-2\files-2.1\56f020e9c27d6a807cc1a74760f6e28d\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVa
riationSettings not found.

     C:\Users\Sandeep Sharma\.gradle\caches\transforms-2\files-2.1\56f020e9c27d6a807cc1a74760f6e28d\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcInd
ex not found.


* 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 2m 34s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                     158.0s (!)
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 cloud_firestore...
The plugin cloud_firestore could not be built due to the issue above.
Running Gradle task 'assembleAarRelease'...

如果这个问题不能解决,那么建议是如何获得这个路径的。/storage/emulated/0/Download 或其他方式。

更新:我刚刚看到 下载_路径_提供者的重现 其中说

这个插件有很多不一致的地方,不应该再使用。可以随意分叉和调整它。

我应该用什么来获得这个路径 /storage/emulated/0/Download.谢谢。

flutter android-gradle-plugin build.gradle gradle-plugin
回答

你必须使用flutter提供的官方包,称为 path_provide 并使用 getDownloadsDirectory() 方法来获取路径。