Android 找不到包含路径的已配置根目录

Android 找不到包含路径的已配置根目录,android,Android,我在执行时出错: @SuppressLint("SetWorldReadable") public void installAPK(File dest) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { dest.setReadable(true, false); Intent intent = new Intent(Intent.ACTION_VIEW)

我在执行时出错:

 @SuppressLint("SetWorldReadable")
    public void installAPK(File dest) {

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
            dest.setReadable(true, false);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setDataAndType(Uri.fromFile(dest), "application/vnd.android.package-archive");
            this.getApplicationContext().startActivity(intent);
        } else {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            Uri fileUri = FileProvider.getUriForFile(this,
                    "com.developerfromjokela.fileprovider",
                    dest);

            intent.setDataAndType(fileUri, "application/vnd.android.package-archive");
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            startActivity(intent);
        }
    }
我提前搜索并在stackoverflow中找到了问题,但这些并不能解决我的问题。我认为这与以前的问题有所不同

AndroidManifest:

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

    </provider>

XML文件路径:

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

使用以下方法:

对于
N
版本

File file = new File(filePathUri.getPath());
Uri photoUri = FileProvider.getUriForFile(getActivity(),getActivity().getPackageName() + ".provider", file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);

你想在N中打开摄像头吗?不,安装apk,但无论如何,我通过添加根路径解决了问题。太棒了,伙计。。。
File file = new File(filePathUri.getPath());
Uri photoUri = FileProvider.getUriForFile(getActivity(),getActivity().getPackageName() + ".provider", file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);