gpt4 book ai didi

android - FileProvider - 名称不能为空

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:01:17 26 4
gpt4 key购买 nike

我的 list 中有以下 FileProvider:

    <provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.android.provider.DataSharing-1"
android:exported="false"
android:grantUriPermissions="true">

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

</provider>

我在应用启动时遇到以下异常:

 java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.IllegalArgumentException: Name must not be empty
at android.app.ActivityThread.installProvider(ActivityThread.java:4793)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Name must not be empty
at android.support.v4.content.FileProvider$SimplePathStrategy.addRoot(FileProvider.java:644)
at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:587)
at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:534)
at android.support.v4.content.FileProvider.attachInfo(FileProvider.java:352)
at android.app.ActivityThread.installProvider(ActivityThread.java:4790) ...

我该如何解决这个问题?我在哪里错过了指定名称?

编辑:

res/xml/paths.xml

<paths xmlns:android="http://schemas.android.com/apk/res/android">

<files-path android:name="my_images" android:path="images/"/>
</paths>

最佳答案

paths.xml 文件的属性中删除 android: 前缀。它应该看起来像:

<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="my_images" path="images/"/>
</paths>

(你也可以去掉 xmlns:android 位,因为它没有被使用,虽然我在 one of mine 中有它,也许是因为 Eclipse 在创建文件时把它放在那里。 ..)

关于android - FileProvider - 名称不能为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24111177/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com