Flutter:资源和资产合并:可以确定标签的类型'路径=;&quot&quot&quort;>'

发布于 2025-01-28 20:20:06 字数 4503 浏览 4 评论 0原文

我正在使用Flutter 3.0中的InappWebView软件包开发一个应用程序。在此软件包中,我们无法在Android设备中的WebView中访问文件。这就是为什么我在androidmanifest.xml文件中添加了提供商,然后在res> value文件夹中添加新文件provider_paths.xml。 时,我将面临错误

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

androidmanifest.xml文件

<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>

但是现在,当我像这样运行我的 强>

<?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>

我该如何解决这个问题?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

短暂陪伴 2025-02-04 20:20:06

1-从res&gt;删除provider_paths.xml

2-添加新的 xml 在res(res&gt; xml)中的文件夹

3-在 xml (新创建的)文件夹中,添加新provider_paths.xml并粘贴此代码

<?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-在 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>

享受!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文