Ionic social-sharing not attaching file (Unable to attach file)

I have a text file saved on my android on location:


What I want to do is to share this file. I have tried to attached it to gmail and send it.

Here is the code:

import { Component } from '@angular/core';
import { File } from '@ionic-native/file/ngx';
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
import { Plugins, FilesystemDirectory, FilesystemEncoding } from '@capacitor/core';

const { Filesystem } = Plugins;

  selector: 'app-home',
  templateUrl: '',
  styleUrls: [''],
export class HomePage {

    private file: File,
    private socialSharing: SocialSharing
  ) {}

  sharefile() {

    this.socialSharing.share(null, null, 'file://' + FilesystemDirectory.Documents + '/mydata/text2.txt', null).then(e => {
      // Success
      alert('File has been shared');
    }).catch(e =>{
      console.log('Share failed:', e);
      alert('file has not been shared: ' + e);


When I select gmail and send the email I get "File has been shared" ... but the file is not attached to the email.

But I'm getting a message: "Unable to attach file"

What I'm I doing wrong?