FileProvider crash - npe attempting to invoke XmlResourceParser on a null String

前端 未结 9 1861
误落风尘
误落风尘 2020-11-28 21:38

This is a part of my manifest:




        
相关标签:
9条回答
  • 2020-11-28 22:10

    You should try it:

      Context context = PostAdapter.this.activity;
                        StringBuilder stringBuilder2 = new StringBuilder();
                        stringBuilder2.append(PostAdapter.this.activity.getPackageName());
                        stringBuilder2.append(".provider");
                        Uri uri;
                        uri = FileProvider.getUriForFile(context,stringBuilder2.toString(), newFile);
    
    0 讨论(0)
  • 2020-11-28 22:12

    Following worked for me.

    mUri = FileProvider.getUriForFile(this,
                        BuildConfig.APPLICATION_ID + ".provider",
                        fileObject);
    
    0 讨论(0)
  • 2020-11-28 22:13

    Here is what i did to fix the issue. I gave fully qualified name in android:name. It works in android 6,7,8

        <provider android:authorities="${applicationId}.opener.provider" 
            android:exported="false" android:grantUriPermissions="true" 
            android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />
        </provider>
    
    0 讨论(0)
提交回复
热议问题