Ionic Native Clipboard build failed?


#1

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?


#2

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


#3

Any solution for this?


#4

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);
      });
  }

#5

what is navigator here? Can you please explain that?


#6

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.


#7

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


#8

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


#9

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


#10

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.


#11

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


#12

@ckc52403050, Can you please check this question?