I am developing an app with InAppWebview package in Flutter 3.0. In this package we can't access file in webview in android device. That's why I added provider in AndroidManifest.xml file and add a new file provider_paths.xml in res>value folder. But now I am facing an error when I run like this

Launching lib/main.dart on M2010J19SI in debug mode...
ERROR:/Users/abir/Documents/Office Work/insurance/android/app/src/main/res/values/provider_paths.xml: Resource and asset merger: Can't determine type for tag '<external-path name="external_files" path="."/>'

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> /Users/abir/Documents/Office Work/insurance/android/app/src/main/res/values/provider_paths.xml: Error: Can't determine type for tag '<external-path name="external_files" path="."/>'

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s
Running Gradle task 'assembleDebug'...                             12.2s
Exception: Gradle task assembleDebug failed with exit code 1

My AndroidManifest.xml file :

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.insurance">
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

  <application android:label="insurance" android:name="${applicationName}" android:icon="@mipmap/ic_launcher">
    <activity android:name=".MainActivity" android:exported="true" 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" />
      <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" />
    <provider android:name="androidx.core.content.FileProvider" android:authorities="com.example.insurance.fileprovider" android:exported="false" android:grantUriPermissions="true">
      <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/>
    </provider>


  </application>
  <queries>
    <!-- If your app opens https URLs -->
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="https" />
    </intent>
    <!-- If your app makes calls -->
    <intent>
      <action android:name="android.intent.action.DIAL" />
      <data android:scheme="tel" />
    </intent>
    <!-- If your sends SMS messages -->
    <intent>
      <action android:name="android.intent.action.SENDTO" />
      <data android:scheme="smsto" />
    </intent>
    <!-- If your app sends emails -->
    <intent>
      <action android:name="android.intent.action.SEND" />
      <data android:mimeType="*/*" />
    </intent>
  </queries>
</manifest>

My provider_paths.xml file :

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-path name="external_files" path="." />
    <external-files-path name="external_files" path="." />
    <!-- FOR SD CARD-->
    <root-path name="sdcard1" path="." />
</paths>

How Can I solve this problem ?

1

There are 1 best solutions below

0
On

1 - Remove your provider_paths.xml from res > value

2 - Add new xml folder in res(res > xml)

3 - Add new provider_paths.xml in xml(newly created) folder and paste this code

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path
        name="external_files"
        path="." />
</paths> 

4 - Replace file provider in AndroidManifest.xml

    <provider android:name="androidx.core.content.FileProvider"
        android:authorities="com.example.insurance.fileprovider"                                             
        android:exported="false"
        android:grantUriPermissions="true">

          <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
              android:resource="@xml/provider_paths"/>

    </provider>

Enjoying!