Ionic Native Clipboard build failed?

I am trying to use clipboard in my Ionic 3 application for Android and iOS. But when run the below command, the build failed.

ionic cordova run android -c

The error:

Can anyone explain why is this happening?

I have the same issue in my today’s created project

Any solution for this?

Alternatively the web clipboard API might work for you.


  /**
   * Copy content from textarea to clipboard
   */
  public copyToClipboard(): void {
    navigator.clipboard.writeText(this.textData);
  }

  /**
   * Paste text from clipboard into textarea
   */
  public pasteFromClipboard(): void {
    navigator.clipboard
      .readText()
      .then(text => {
        this.textData += text;
      })
      .catch(err => {
        console.error('Failed to read clipboard contents: ', err);
      });
  }
1 Like

what is navigator here? Can you please explain that?

navigator is a global browser API, you do not need to import anything. It is just like “document” for example.

I just testet it on Android, it didn’t work. Just worked on Chrome desktop and i guess all other modern desktop browsers. It seems this technology is very new, nevertheless it could be integrated as browser interface into the plugin. I’m going to open a PR when I have a chance.

Did you get any hint about the problem of ionic native clipboard plugin? Why is it not compiling?

Same issue happening. Hope a fix is coming up soon.

Could’t report the issue in their github. Any news on the fix?

Why can’t we report that? btw I’m now trying to use an older version of the @ionic-native/clipboard. See if it works.

The older version works! I’m now using the v1.1.1
To use an older version of cordova-clipboard, remove the installed one first:

cordova plugin remove cordova-clipboard
npm uninstall --save @ionic-native/clipboard

Then install the specific version:

ionic cordova plugin add cordova-clipboard@v1.1.1
npm i --save @ionic-native/clipboard

versions: https://github.com/ihadeed/cordova-clipboard/releases

2 Likes

@ckc52403050, Can you please check this question?