0 votes
Hello,

When I try the sample code in the Unity package , nothing happens and I have this in logcat :

06-13 10:38:23.781  4511  4526 I Unity   : java.lang.NullPointerException: 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

06-13 10:38:23.781  4511  4526 I Unity   :     at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:561)

06-13 10:38:23.781  4511  4526 I Unity   :     at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:535)

06-13 10:38:23.781  4511  4526 I Unity   :     at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:377)

06-13 10:38:23.781  4511  4526 I Unity   :     at com.SlavaObninsk.pdfreader.Logic.OpenDocLocal(Logic.java:60)

06-13 10:38:23.781  4511  4526 I Unity   :     at com.unity3d.player.UnityPlayer.nativeRender(Native Method)

06-13 10:38:23.781  4511  4526 I Unity   :     at com.unity3d.player.UnityPlayer.a(Unknown Source)

06-13 10:38:23.781  4511  4526 I Unity   :     at com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source)

06-13 10:38:23.781  4511  4526 I Unity   :     at android.os.Handler.dispatc

Could you please help me ?

Cheers,
asked Jun 13, 2017 by o.lunot (120 points)

1 Answer

0 votes
Add to android manifest

<provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.SlavaObninsk.Test.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>
answered Jun 14, 2017 by IndieYP (1,730 points)
Thanks for your answer,

That is actually the content of the android manifest included in your example code.

The thing is it's working on a Samsung Galaxy Tab from 2014 with Android 5.0 but the same app is not working on my Nexus 5X / Android 7.1, neither on my Galaxy S8 / Android 7.0.

It seems to work on a One+ with Android 6.0, so basically the issue occurs with my devices running Android 7.x.
Change  android:authorities="com.SlavaObninsk.Test.provider" to android:authorities=" you bundle name.provider"
It works, thank you very much.
Welcome to IndieYP Q&A, where you can ask questions and receive answers from other members of the community.
27 questions
23 answers
42 comments
1,529 users