Flutter无法找到具有授权者的元数据

我有一个正在使用flutter_webview_plugin 0.3.8的应用程序。我在webview中打开一个网页并显示其内容。页面中有一个按钮,当您按下按钮时,它应该像在chrome这样的普通网络浏览器中一样打开文件资源管理器。该按钮在chrome中工作正常,并打开一个底部小部件以选择一个动作(相机,文件, ...)。但是在我的Web视图中,它崩溃并显示错误Couldn't find meta-data for provider with authority com.example.booshehr.fileprovider。完整的错误是:

W/System.err(15213): java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.example.booshehr.fileprovider
W/System.err(15213):    at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:606)
W/System.err(15213):    at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:579)
W/System.err(15213):    at androidx.core.content.FileProvider.geturiForFile(FileProvider.java:417)
W/System.err(15213):    at com.flutter_webview_plugin.WebviewManager.getOutputFilename(WebviewManager.java:272)
W/System.err(15213):    at com.flutter_webview_plugin.WebviewManager.access$800(WebviewManager.java:42)
W/System.err(15213):    at com.flutter_webview_plugin.WebviewManager$3.onShowFileChooser(WebviewManager.java:211)
W/System.err(15213):    at In.a(PG:145)
W/System.err(15213):    at uE0.runFileChooser(PG:2)
W/System.err(15213):    at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(15213):    at android.os.MessageQueue.next(MessageQueue.java:325)
W/System.err(15213):    at android.os.Looper.loop(Looper.java:142)
W/System.err(15213):    at android.app.activityThread.main(activityThread.java:6710)
W/System.err(15213):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err(15213):    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
W/System.err(15213):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
F/chromium(15213): [FATAL:jni_android.cc(249)] Please include Java exception stack in crash report
F/libc    (15213): Fatal signal 5 (SIGTRAP),code 1 in tid 15213 (xample.booshehr)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'lge/elsa_global_com/elsa:8.0.0/OPR1.170623.032/18325232422a1:user/release-keys'
Revision: '12'
ABI: 'arm64'
pid: 15213,tid: 15213,name: xample.booshehr  >>> com.example.booshehr <<<
signal 5 (SIGTRAP),code 1 (TRAP_BRKPT),fault addr 0x714216eb04
    x0   0000000000000000  x1   0000000000000081  x2   000000007fffffff  x3   0000000000000000
    x4   0000000000000000  x5   0000000000000000  x6   0000000000000000  x7   7f7f7f7f7fffff7f
    x8   0000000000000000  x9   0000000000000000  x10  0000000000000001  x11  0000000000000000
    x12  0000007134d6ff00  x13  0000000000000000  x14  0000000000000000  x15  000000716228c000
    x16  000000715dfd2208  x17  000000715df25c50  x18  000000006fba3d30  x19  0000007fd17f5c70
    x20  0000007fd17f5c78  x21  0000007fd17f5c80  x22  000000000000004f  x23  000000715dfd4808
    x24  0000007143e3f000  x25  0000007fd17f5e70  x26  0000000000000001  x27  0000007162612a48
    x28  0000007162612a48  x29  0000007fd17f5c60  x30  000000714216e9c4
    sp   0000007fd17f57b0  pc   000000714216eb04  pstate 0000000060000000
backtrace:
    #00 pc 0000000001e9fb04  /data/app/com.android.chrome-HU8bsIOJpUMqks882ELhSA==/base.apk (offset 0xc19000)
    #01 pc 0000000001e9f9c0  /data/app/com.android.chrome-HU8bsIOJpUMqks882ELhSA==/base.apk (offset 0xc19000)

我尝试将provider添加到a​​ndroidmanifest,仍然是相同的错误:

<provider
                android:name="androidx.core.content.FileProvider"
                android:authorities="${applicationid}.fileProvider"
                android:exported="false"
                android:granturiPermissions="true"
                tools:replace="android:authorities">
            <meta-data
                    android:name="android.support.FILE_PROVIDER_PATHS"
                    android:resource="@xml/filepaths"
                    tools:replace="android:resource" /> 
</provider>

我的@xml/filepaths是:

<?xml version="1.0" encoding="utf-8"?> 
<paths> 
<files-path name="myapp" path="images/"/>
</paths>

然后我尝试将android:authorities="${applicationid}.fileProvider"更改为android:authorities="${applicationid}.myownFileProvider",仍然是相同的错误。

请帮助我。

dfasdfewrt 回答:Flutter无法找到具有授权者的元数据

某些软件包可能与androids FileProvider冲突。您必须在pubspec.yaml中查看包裹清单。通常,读取或写入文件的软件包会与此冲突。如flutter_downloader和...。 我的建议是创建一个新项目,然后向其中添加flutter_webview_plugin 0.3.8。然后,每次添加软件包时,通过重新启动应用程序一个接一个地添加其他软件包。其中之一可能会发生冲突。然后,您必须删除有冲突的软件包并使用其他软件包,或者在其网站或其他内容中阅读其文档。看看是否可以找到解决方案。

本文链接:https://www.f2er.com/3160837.html

大家都在问