gpt4 book ai didi

android - Flutter android 应用程序 - android.support.v4.content.FileProvider 未找到

转载 作者:行者123 更新时间:2023-12-02 14:16:06 32 4
gpt4 key购买 nike

Flutter android 应用程序,我想下载并写入文件,但出现此错误:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference

因此,为了解决上述错误,我添加了提供程序和 xmlfile 及其依赖项,但现在我收到错误,找不到“android.support.v4.content.FileProvider”

<application> 
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
</application




implementation 'com.android.support:support-v4:28.0.0'
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation "com.android.support:support-core-utils:28.0.0"

最佳答案

是的,我解决了

我想写入文件,这就是我添加 <provider></provider> 的原因但我以简单的方式编写我的文件,所以我删除 <provider>从那里标记

我使用以下方式写入文件:

final response2 = await http.get(url);
var bytes = response2.bodyBytes;
var dirc = Directory("/storage/emulated/0/MyFiles");
if(dirc.exists()!=true){
dirc.create();
}
File file = new File('${dirc.path}/$filename');
var newFile = await file.writeAsBytes(bytes);
await newFile.create();
if(newFile.exists() != null) {
print("file create successfully");
// showNotification
}

you should ask storage permission before write file

关于android - Flutter android 应用程序 - android.support.v4.content.FileProvider 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56334736/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com