Skip to content

IllegalArgumentException: Couldn't find meta-data for provider with authority {packageId}.fileProvider #55

@Samurai016

Description

@Samurai016

Issue

When OpenFile.open(filePath); is fired, this exception is thrown:

E/MethodChannel#open_file( 3078): Failed to handle method call
E/MethodChannel#open_file( 3078): java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.example.musiker.fileProvider
E/MethodChannel#open_file( 3078): 	at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:606)
E/MethodChannel#open_file( 3078): 	at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:579)
E/MethodChannel#open_file( 3078): 	at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:417)
E/MethodChannel#open_file( 3078): 	at com.crazecoder.openfile.OpenFilePlugin.startActivity(OpenFilePlugin.java:130)
E/MethodChannel#open_file( 3078): 	at com.crazecoder.openfile.OpenFilePlugin.onMethodCall(OpenFilePlugin.java:88)
E/MethodChannel#open_file( 3078): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#open_file( 3078): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#open_file( 3078): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/MethodChannel#open_file( 3078): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#open_file( 3078): 	at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#open_file( 3078): 	at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#open_file( 3078): 	at android.app.ActivityThread.main(ActivityThread.java:6694)
E/MethodChannel#open_file( 3078): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#open_file( 3078): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#open_file( 3078): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter ( 3078): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Couldn't find meta-data for provider with authority com.example.musiker.fileProvider, null)

Example code

OpenFile.open(filePath);

Setup

Device: Xiaomi Mi A2 Lite
Android version: 9

AndroidManifest.xml

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

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="musiker"
        android:icon="@mipmap/ic_launcher">
        <activity>
            ...
        </activity>

        <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>
        <provider
            android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
            android:authorities="${applicationId}.flutter_downloader.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>
    </application>
</manifest>

Dependencies

...
dio: ^2.1.16
flutter_downloader: ^1.2.1
path_provider: ^1.2.0
path: ^1.6.2
open_file: ^2.0.3
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions