安卓清单文件错误 @xml/file路径

3
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="gt.otomat">

    <uses-feature android:name="android.hardware.camera2" android:required="true"/>

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".otomat">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="${applicationId}.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"
                ></meta-data>
        </provider>

    </application>

</manifest>

我从Github上复制了这段代码,但出现了错误。我正在使用Tesstwo库进行OCR(Tesseract OCR)。 在这个位置上,我有一个错误"android:resource="@xml/file_paths"。我复制了所有的清单、主活动和activity_main.xml,但它仍然报错。

谢谢你的帮助...


2
错误信息是什么?如果它是像“未找到资源”之类的东西,那么您可能错过了复制“res/xml/”文件夹。 - Mike M.
2个回答

5

请尝试以下操作:

首先,在应用程序中添加您的提供者标签

<application
...
android:theme="@style/AppTheme">

<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="zm.mytestapplication.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths"></meta-data>
</provider>

在你的 xml 文件夹中创建一个名为 file_path 的文件,如下所示:

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

<external-path
    name="my_images"   
    path="Android/data/org.projects.cameraapp/files/Pictures" />

  </paths>

确保在 .xml 文件中使用正确的路径


3

您正在使用 provider 定义文件路径。首先在 res 目录下创建 xml 文件夹。然后创建 xml 文件(在您的情况下为 file_paths)。在您的 xml 文件中按以下方式定义路径。

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

在这里,path是您希望存储文件的存储路径。 有关更多信息,请访问Google文档


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接