我有一个应用程序正在使用flutter_webview_plugin 0.3.8
。我在webview中打开一个网页并显示其内容。页面中有一个按钮,当你按下它时,它应该会像在chrome等普通web浏览器中一样打开文件资源管理器。这个按钮在chrome中工作得很好,它打开了一个底部的小部件来选择一个动作(相机、文件…(。但在我的网络视图中,它崩溃了,出现了错误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
添加到androidmanifest,仍然是相同的错误:
<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"
,仍然是相同的错误。
请帮我一下。
从抛出的日志来看,似乎是在使用意向启动安卓应用程序。WebView中显示的按钮有什么功能?您可以使用android_intent插件通过意向在android上启动应用程序,即
if (Platform.isAndroid) {
final AndroidIntent intent = AndroidIntent(
action: 'action_view', // Update with the required action flag
data: 'package:com.example.booshehr.fileprovider',
);
await intent.launch();
}
这个问题的另一个可能原因是,您可能使用的插件尚未支持您运行的平台。