Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to find configured root that contains #754

Closed
samarthagarwal opened this issue Jan 18, 2017 · 24 comments
Closed

Failed to find configured root that contains #754

samarthagarwal opened this issue Jan 18, 2017 · 24 comments
Labels
Milestone

Comments

@samarthagarwal
Copy link

I am getting the following error when trying to share a file from a remote URL.

Error Screenshot

Here is my code.

var options = {
          message: 'share this', // not supported on some apps (Facebook, Instagram)
          subject: 'the subject', // fi. for email
          files: ["http://ngcordova.com/img/ngcordova-logo.png"], // an array of filenames either locally or remotely
          url: 'http://ngcordova.com/',
          chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title
        }

        var onSuccess = function (result) {
          alert("Share completed? " + result.completed); // On Android apps mostly return false even while it's true
          alert("Shared to app: " + result.app); // On Android result.app is currently empty. On iOS it's empty when sharing is cancelled (result.completed=false)
        }

        var onError = function (msg) {
          alert("Sharing failed with message: " + msg);
        }

        window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);
@rebrandsoftware
Copy link

I'm having the same failure and error message when I try to send a base64 encoded file, with this code:

	var options = {
	  message: tweetText, // not supported on some apps (Facebook, Instagram)
	  //subject: 'the subject', // fi. for email
	  files: [picture], // an array of filenames either locally or remotely
	  chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title
	};
	
	var onSuccess = function(result) {
	  console.log("Share completed? " + result.completed); // On Android apps mostly return false even while it's true
	  console.log("Shared to app: " + result.app); // On Android result.app is currently empty. On iOS it's empty when sharing is cancelled (result.completed=false)
	};
	
	var onError = function(msg) {
	  console.log("Sharing failed with message: " + msg);
	};
	
	window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);

@EddyVerbruggen
Copy link
Owner

What does Google tell us about this error?

@samarthagarwal
Copy link
Author

I am pretty sure it is something related to file permissions. I checked the permissions in the manifest file and it is okay. I could not find a solution that is why I posted here.

@angeagu
Copy link

angeagu commented Jan 19, 2017

Same here with this code for trying to share file in /storage/emulated/0/

Code:

`var options = {
message: 'share this', // not supported on some apps (Facebook, Instagram)
//subject: 'the subject', // fi. for email
files: ['file:///storage/emulated/0/CalendarExport.json'], // an array of filenames either locally or remotely
chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title
}

            var onSuccess = function (result) {
                alert("Share completed? " + result.completed); // On Android apps mostly return false even while it's true
                alert("Shared to app: " + result.app); // On Android result.app is currently empty. On iOS it's empty when sharing is cancelled (result.completed=false)
            }

            var onError = function (msg) {
                alert("Sharing failed with message: " + msg);
            }

            window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);`

@angeagu
Copy link

angeagu commented Jan 19, 2017

Think I got a clue:

I saw in /res/xml/sharing_paths.xml the following element:

<external-files-path name="socialsharing_downloads" path="socialsharing-downloads/" />

Checking my android.support.v4.content.FileProvider, there's no tag for that element, just:

private static final java.lang.String META_DATA_FILE_PROVIDER_PATHS = "android.support.FILE_PROVIDER_PATHS";
private static final java.lang.String TAG_ROOT_PATH = "root-path";
private static final java.lang.String TAG_FILES_PATH = "files-path";
private static final java.lang.String TAG_CACHE_PATH = "cache-path";
private static final java.lang.String TAG_EXTERNAL = "external-path";
private static final java.lang.String ATTR_NAME = "name";
private static final java.lang.String ATTR_PATH = "path";

So this class is using "external-path" as tag, not "external-files-path". I commented that element
in sharing_paths.xml and added following:
<external-path name="external_path" path="." />

Then, I ran application again and tried to share a PDF file with Gmail application, and the file appears
now as attached.
Now the problem is that when I send the message, file is not really sent; just the message without
the file.

Hope this give some light on the issue and let's check if we can manage to make it work....

@rebrandsoftware
Copy link

Just FYI my code sending base64 (which shouldn't even need to access a file location, right? Or perhaps there is a temp file being created?) works fine if I revert back to 5.1.1 of cordova-plugin-x-socialsharing on NPM.

@samarthagarwal
Copy link
Author

I can confirm @rebrandsoftware that 5.1.1 works.

@angeagu
Copy link

angeagu commented Jan 20, 2017

Have removed plugin and reinstalled version 5.1.1 too and works.
Thanks for the info @rebrandsoftware

@EddyVerbruggen
Copy link
Owner

@rebrandsoftware Any particular reason to use 5.1.1 over 5.1.2 or 5.1.3? Did you test those and confirmed they have the same issue?

I'm asking because my main suspect is the PR I accepted recently which was part of 5.1.4..

@macdonst
Copy link
Contributor

@EddyVerbruggen everything works fine up to 5.1.3 and the bug appears once I upgrade to 5.1.4.

@EddyVerbruggen
Copy link
Owner

@macdonst thanks for confirming that - #748 is doing more harm than good it seems.

@EddyVerbruggen
Copy link
Owner

Although I can think of more fun things, I will be solving this this weekend.

@EddyVerbruggen
Copy link
Owner

I can reproduce the crash that was introduced with 5.1.4, but can't reproduce the problem that it tried to solve.

However, I've now pushed a change to this repo's master branch that's supposed to fix the problem for all cases.

Would be great if someone that had the problem with 5.1.3 and before on Android SDK 24+ could verify it works correctly.

@rebrandsoftware
Copy link

Hey, no reason I chose 5.1.1 other than I saw someone else having luck with 5.1.1. I will see what happens with other versions in just a moment.

@EddyVerbruggen
Copy link
Owner

@rebrandsoftware no need as @macdonst already confirmed it, but if you want: please verify the latest from github works fine (not released to npm yet)

@rebrandsoftware
Copy link

I can verify that the error I was having has been fixed in the latest from Github. However, I was testing on Android SDK 23. Sounds like you will still need confirmation from others with SDK 24+.

@EddyVerbruggen
Copy link
Owner

Correct. But a regression test never hurts, cheers!

@nicobytes
Copy link

The same error =( When I use shareViaWhatsApp
screenshot from 2017-01-24 16-13-47

@nicobytes
Copy link

Just commenting that if anyone has a workaround, a temp hack, I'd definitely appreciate it.

@nicobytes
Copy link

nicobytes commented Jan 24, 2017

Ok ok I'm sorry I tried with cordova plugin add cordova-plugin-x-socialsharing and not work, but I tried cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git and now the plugin work!!!

@EddyVerbruggen
Copy link
Owner

@nicobytes so you've essentially tested the fix I asked folks to test, that's awesome 😄
I'll release an update to npm today.

@EddyVerbruggen
Copy link
Owner

Released with 5.1.6.

@EddyVerbruggen EddyVerbruggen added this to the 5.1.6 milestone Jan 25, 2017
@michaelpeterlee
Copy link

I confirm now working again for Android, was not sharing files due to prior regression.

@sdaly31
Copy link

sdaly31 commented Feb 14, 2022

I am having this same issue on 6.0.3. Is anyone else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants