triniwiz / nativescript-videorecorder

:video_camera: NativeScript plugin for Video Recording . :video_camera:
Apache License 2.0
43 stars 29 forks source link

App crash with IllegalArgumentException: Failed to find configured root that contains /storage/emulated... #46

Closed wanpeng2008 closed 6 years ago

wanpeng2008 commented 6 years ago

Here is the call to the videorecorder:

    ngOnInit() {
        const options: VideoRecorderOptions = {
            hd: false,
            saveToGallery: false
        }
        this._videoRecorder = new VideoRecorder(options)
        this._videoRecorder.requestPermissions().then();
    }
    onTakeVideo() {
        if (VideoRecorder.isAvailable()) {
            this._videoRecorder.record().then((recordResult: RecordResult) => {
                console.log(recordResult.file)
                this.loadVideoFiles();
            }).catch((err) => {
                console.log(err)
            });
        } else {
            dialogs.alert('未发现可用的拍照设备').then();
        }
    }

Here is the error message:

Error: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Android/data/org.nativescript.MarketingAssistant/files/VID_1529329737452.mp4
JS:     android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:738)
JS:     android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:417)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:970)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:954)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:946)
JS:     com.tns.NativeScriptActivity.onRequestPermissionsResult(NativeScriptActivity.java:72)
JS:     android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7843)
JS:     android.app.Activity.dispatchActivityResult(Activity.java:7694)
JS:     android.app.ActivityThread.deliverResults(ActivityThread.java:4928)
JS:     android.app.Activi...

tns info:

✔ Component nativescript has 4.1.0 version and is up to date.
✔ Component tns-core-modules has 4.1.0 version and is up to date.
✔ Component tns-android has 4.1.3 version and is up to date.
✔ Component tns-ios has 4.1.0 version and is up to date.
wanpeng2008 commented 6 years ago

it works after i remove the provider section in 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/provider_paths" />
        </provider>

also the xml/provider_paths.xml

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

</paths>