Flutter:资源和资产合并:可以确定标签的类型'路径=;&quot&quot&quort;>'
我正在使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1-从res&gt;删除
provider_paths.xml
值2-添加新的 xml 在res(res&gt; xml)中的文件夹
3-在 xml (新创建的)文件夹中,添加新
provider_paths.xml
并粘贴此代码4-在 androidmanifest.xml
享受!
1 - Remove your
provider_paths.xml
from res > value2 - Add new xml folder in res(res > xml)
3 - Add new
provider_paths.xml
in xml(newly created) folder and paste this code4 - Replace file
provider
in AndroidManifest.xmlEnjoying!