Missing PDF application:Error: java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/

file-system

#1

I have created Angular + TypeScript application. When i try to open file downloaded withing the internal directory of the app i get this error:

Missing PDF application:Error: java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.appname/files/test.pdf
JS:     android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:719)
JS:     android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:404)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:957)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:941)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:933)
JS:     com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:12)
JS:     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:585)
JS:     org.nativescript.widgets.Async$Http$1$1.run(Async.java:486)
JS:     android.os.Handler.handleCallback(Handler.java:739)
JS:     android.os.Handler.dispatchMessage(Handler.java:95)
JS:     android.os.Looper.loop(Looper.java:145)
JS:     android.app.ActivityThread.main(ActivityThread.java:5951)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     java.lang.reflect.Method.invoke(Method.java:372)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)

I added file provider under application in “AndroidManifest.xml”. Here is the configuration.

<application
		android:name="com.tns.NativeScriptApplication"
		android:allowBackup="true"
		android:icon="@drawable/icon"
		android:label="@string/app_name"
		android:theme="@style/AppTheme" >
		
		<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/provider_paths"/>
				
        </provider>


		<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

		<service android:name="org.nativescript.plugins.firebase.MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>
        <service android:name="org.nativescript.plugins.firebase.MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
		
		<activity
			android:name="com.tns.NativeScriptActivity"
			android:label="@string/title_name"
			android:configChanges="keyboardHidden|orientation|screenSize"
			android:theme="@style/LaunchScreenTheme">

			<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />

			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
		<activity android:name="com.facebook.FacebookActivity"
			android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
			android:theme="@android:style/Theme.Translucent.NoTitleBar"
			android:label="@string/app_name" />

		<activity android:name="com.tns.ErrorReportActivity"/>
		
	</application>

Here is the provider_paths.xml

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

Her is my code to open file using external application.

var ff:File = new java.io.File(file.path);
var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
intent.addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION);
var fileURI = (android.support.v4.content).FileProvider.getUriForFile(application.android.context, application.android.nativeApp.getPackageName() +".provider", ff);
intent.setDataAndType(fileURI, "application/pdf");
application.android.currentContext.startActivity(android.content.Intent.createChooser(intent, 'Open'));

#2

hi shivaji_babar, did you find what was wrong?, I have exactly the same issue