Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
517 views
in Technique[技术] by (71.8m points)

android - Issue in InAppWebView plugin

I was facing with this error while using InAppWebView Plugin, please guide where im doing mistake. How to resolve this?

W/System.err(30308): java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.nine_am.app.flutter_inappwebview.fileprovider
W/System.err(30308):    at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:606)
W/System.err(30308):    at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:579)
W/System.err(30308):    at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:417)
W/System.err(30308):    at com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewChromeClient.getOutputUri(InAppWebViewChromeClient.java:1052)
W/System.err(30308):    at com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewChromeClient.getPhotoIntent(InAppWebViewChromeClient.java:938)
W/System.err(30308):    at com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewChromeClient.startPhotoPickerIntent(InAppWebViewChromeClient.java:895)
W/System.err(30308):    at com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewChromeClient.onShowFileChooser(InAppWebViewChromeClient.java:799)
W/System.err(30308):    at co.runFileChooser(PG:10)
W/System.err(30308):    at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(30308):    at android.os.MessageQueue.next(MessageQueue.java:336)
W/System.err(30308):    at android.os.Looper.loop(Looper.java:181)
W/System.err(30308):    at android.app.ActivityThread.main(ActivityThread.java:7520)
W/System.err(30308):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err(30308):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
W/System.err(30308):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
F/chromium(30308): [FATAL:jni_android.cc(249)] Please include Java exception stack in crash report
F/libc    (30308): Fatal signal 5 (SIGTRAP), code -6 (SI_TKILL) in tid 30308 (com.nine_am.app), pid 30308 (com.nine_am.app)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

If added provider tag it shows error like this, look over it, and I added provider_paths.xml file in the path res>xml>provider_paths.xml

    E/AndroidRuntime(16711): java.lang.RuntimeException: Unable to get provider com.nine_am.app.flutter_inappwebview.InAppWebViewFileProvider: java.lang.ClassNotFoundException: Didn't find class "com.nine_am.app.flutter_inappwebview.InAppWebViewFileProvider" on path: DexPathList[[zip file "/data/app/com.nine_am.app-ytDaqFCP0M6-QPYD_HI-wQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.nine_am.app-ytDaqFCP0M6-QPYD_HI-wQ==/lib/arm64, /data/app/com.nine_am.app-ytDaqFCP0M6-QPYD_HI-wQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
E/AndroidRuntime(16711):    at android.app.ActivityThread.installProvider(ActivityThread.java:7152)
E/AndroidRuntime(16711):    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6630)
E/AndroidRuntime(16711):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6525)
E/AndroidRuntime(16711):    at android.app.ActivityThread.access$1400(ActivityThread.java:220)
E/AndroidRuntime(16711):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1883)
E/AndroidRuntime(16711):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(16711):    at android.os.Looper.loop(Looper.java:224)
E/AndroidRuntime(16711):    at android.app.ActivityThread.main(ActivityThread.java:7520)
E/AndroidRuntime(16711):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(16711):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/AndroidRuntime(16711):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
E/AndroidRuntime(16711): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.nine_am.app.flutter_inappwebview.InAppWebViewFileProvider" on path: DexPathList[[zip file "/data/app/com.nine_am.app-ytDaqFCP0M6-QPYD_HI-wQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.nine_am.app-ytDaqFCP0M6-QPYD_HI-wQ==/lib/arm64, /data/app/com.nine_am.app-ytDaqFCP0M6-QPYD_HI-wQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]

Here is my manifest.xml, Please look below

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nine_am.app">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="9am"
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/launcher_icon">
        <provider
           android:name="com.com.nine_am.app.flutter_inappwebview.InAppWebViewFileProvider"
           android:authorities="${applicationId}.flutter_inappwebview.fileprovider"
           android:exported="false"
           android:grantUriPermissions="true">
            <meta-data
              android:name="android.support.FILE_PROVIDER_PATHS"
              android:resource="@xml/provider_paths" />
        </provider>
        <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">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <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>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

Please look over this all and give me a solution. Thanks in Advance!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

regiser your provider in AndroidManifest.xml

<provider
    android:name="com.com.nine_am.app.flutter_inappwebview.InAppWebViewFileProvider"
    android:authorities="${applicationId}.flutter_inappwebview.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths" />
</provider>

EDIT

Add multidex into android

see here are the steps https://developer.android.com/studio/build/multidex


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...