Runtime error: Attempt to invoke virtual method ‘android.content.res.XmlResourceParser

I’m getting the following error when using version 1.0.24 (after adding the provider).
Did anyone face this? (it was working with the previous version…)

10x!!!

Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.PackageItemInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference parsePathStrategy FileProvider.java:583 getPathStrategy FileProvider.java:557 getUriForFile FileProvider.java:399 getURI ShareFile.java:135 open ShareIntent.java:49 open GenericShare.java:18 open RNShareModule.java:50 invoke Method.java invoke JavaMethodWrapper.java:374 invoke JavaModuleWrapper.java:162 run NativeRunnable.java handleCallback Handler.java:751 dispatchMessage Handler.java:95 dispatchMessage MessageQueueThreadHandler.java:31 loop Looper.java:154 run MessageQueueThreadImpl.java:194 run Thread.java:761

2 thoughts on “Runtime error: Attempt to invoke virtual method ‘android.content.res.XmlResourceParser

  1. Rebuild solved this one.
    For those coming from version 1.0.23 to 1.0.24, you need to:

    1. Add to .\android\app\src\main\AndroidManifest.xml, in section:
    <provider
      android:name="android.support.v4.content.FileProvider"
      android:authorities="${applicationId}.provider"
      android:grantUriPermissions="true"
      android:exported="false">
    </provider>
    
    1. Add to .\android\app\src\main\java\com\anashim\MainApplication.java
      (you already added the package when you installed this):
    import cl.json.ShareApplication;
    ...
    public class MainApplication extends Application implements ReactApplication, ShareApplication  {
    ...
      @Override
      public String getFileProviderAuthority() {
             return "${applicationId}.provider";
      }  
    
  2. I had to put on main application part the package name hardcode and with an if debug since my debug package name ends in .debug and in manifest left it fetching from graddle and no issue, after all I wasn’t sharing a base64, and 1.0.23 doesn’t work on andoird Oreo

Comments are closed.

Runtime Error: Attempt to invoke virtual method \’android.content.res.XmlResourceParser

{ error: ‘Attempt to invoke virtual method ‘android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)’ on a null object reference’ }

I take an image with react-native-view-shot that saves it in:

file:///data/data/com.my.package/cache/ReactNative-snapshot-image-385792666.jpg

Now I’m trying this filepaths.xml:

<cache-path name="ReactNative" path="." />

I have already tried files-path or external-path, none of this works.

AndroidManifest.xml

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

Environment

  • React Native version: 0.57
  • React Native platform + platform version: Android 5.1

react-native-share

Version: 1.1.2

PS. I have already seen the issue with the same title but it has not solved my problem

1 thought on “Runtime Error: Attempt to invoke virtual method \’android.content.res.XmlResourceParser

  1. Too much time in front of the PC to write code will make you see bugs where there are not…

    missing “.provider” in getFileProviderAuthority

    Sorry for creating this issue and thank you for your work.

Comments are closed.

Runtime error: Attempt to invoke virtual method ‘android.content.res.XmlResourceParser

I’m getting the following error when using version 1.0.24 (after adding the provider).
Did anyone face this? (it was working with the previous version…)

10x!!!

Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.PackageItemInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference parsePathStrategy FileProvider.java:583 getPathStrategy FileProvider.java:557 getUriForFile FileProvider.java:399 getURI ShareFile.java:135 open ShareIntent.java:49 open GenericShare.java:18 open RNShareModule.java:50 invoke Method.java invoke JavaMethodWrapper.java:374 invoke JavaModuleWrapper.java:162 run NativeRunnable.java handleCallback Handler.java:751 dispatchMessage Handler.java:95 dispatchMessage MessageQueueThreadHandler.java:31 loop Looper.java:154 run MessageQueueThreadImpl.java:194 run Thread.java:761

3 thoughts on “Runtime error: Attempt to invoke virtual method ‘android.content.res.XmlResourceParser

  1. Rebuild solved this one.
    For those coming from version 1.0.23 to 1.0.24, you need to:

    1. Add to .\android\app\src\main\AndroidManifest.xml, in section:
    <provider
      android:name="android.support.v4.content.FileProvider"
      android:authorities="${applicationId}.provider"
      android:grantUriPermissions="true"
      android:exported="false">
    </provider>
    
    1. Add to .\android\app\src\main\java\com\anashim\MainApplication.java
      (you already added the package when you installed this):
    import cl.json.ShareApplication;
    ...
    public class MainApplication extends Application implements ReactApplication, ShareApplication  {
    ...
      @Override
      public String getFileProviderAuthority() {
             return "${applicationId}.provider";
      }  
    
  2. Pingback: 안전공원
  3. Pingback: devsecops

Comments are closed.

Runtime Error: Attempt to invoke virtual method \’android.content.res.XmlResourceParser

{ error: ‘Attempt to invoke virtual method ‘android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)’ on a null object reference’ }

I take an image with react-native-view-shot that saves it in:

file:///data/data/com.my.package/cache/ReactNative-snapshot-image-385792666.jpg

Now I’m trying this filepaths.xml:

<cache-path name="ReactNative" path="." />

I have already tried files-path or external-path, none of this works.

AndroidManifest.xml

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

Environment

  • React Native version: 0.57
  • React Native platform + platform version: Android 5.1

react-native-share

Version: 1.1.2

PS. I have already seen the issue with the same title but it has not solved my problem

1 thought on “Runtime Error: Attempt to invoke virtual method \’android.content.res.XmlResourceParser

  1. Too much time in front of the PC to write code will make you see bugs where there are not…

    missing “.provider” in getFileProviderAuthority

    Sorry for creating this issue and thank you for your work.

Comments are closed.