WalletConnect / walletconnect-monorepo

WalletConnect Monorepo
Apache License 2.0
1.46k stars 715 forks source link

`SignClient.init` not working on Android #1975

Closed clemente-xyz closed 1 year ago

clemente-xyz commented 1 year ago

Describe the bug When trying to initialise the SignClient on Android Emulator, I'm getting the following errors:

 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.

 LOG  There was an error initializing the Wallet Connect client

 ERROR  {"context": "core"} WebSocket connection failed for URL: wss://relay.walletconnect.com?auth=<MY_AUTH_KEY>&projectId=<MY_PROJECT_ID>&ua=wc-2%2Fjs-2.4.0%2Funknown-%2Freact-native
 ERROR  {"context": "client"} WebSocket connection failed for URL: wss://relay.walletconnect.com?auth=<MY_AUTH_KEY>&projectId=<MY_PROJECT_ID>&ua=wc-2%2Fjs-2.4.0%2Funknown-%2Freact-native
 WARN  Possible Unhandled Promise Rejection (id: 0):
Error: WebSocket connection failed for URL: wss://relay.walletconnect.com?auth=<MY_AUTH_KEY>&projectId=<MY_PROJECT_ID>&ua=wc-2%2Fjs-2.4.0%2Funknown-%2Freact-native
Error: WebSocket connection failed for URL: wss://relay.walletconnect.com?auth=<MY_AUTH_KEY>&projectId=<MY_PROJECT_ID>&ua=wc-2%2Fjs-2.4.0%2Funknown-%2Freact-native
    at emitError (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=io.lisk.mobile&modulesOnly=false&runModule=true:402685:46)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=io.lisk.mobile&modulesOnly=false&runModule=true:402620:38)
    at call (native)
    at dispatchEvent (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=io.lisk.mobile&modulesOnly=false&runModule=true:29887:31)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=io.lisk.mobile&modulesOnly=false&runModule=true:30113:31)
    at apply (native)
    at emit (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=io.lisk.mobile&modulesOnly=false&runModule=true:2081:40)
    at apply (native)
    at __callFunction (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=io.lisk.mobile&modulesOnly=false&runModule=true:21055:36)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=io.lisk.mobile&modulesOnly=false&runModule=true:20805:31)
    at __guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=io.lisk.mobile&modulesOnly=false&runModule=true:21003:15)
    at callFunctionReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=io.lisk.mobile&modulesOnly=false&runModule=true:20804:21)

But for iOS, with the same configuration and variables, works perfectly.

I'm initialising the client this way:

import SignClient from '@walletconnect/sign-client';

import pkg from '../../../package.json';

export let signClient;

export async function createSignClient(icon) {
  const res = await SignClient.init({
    projectId: process.env.PROJECT_ID,
    metadata: {
      name: pkg.name,
      description: pkg.description,
      url: pkg.homepage,
      icons: [icon],
    },
  });

  signClient = res;

  return signClient;
}

I'm following all the instructions for setting-up WC on RN.

SDK Version (if relevant)

To Reproduce Steps to reproduce the behavior:

  1. Setup a WC app on RN.
  2. Run it on Android Emulator.
  3. See error on terminal

Expected behavior SignClient.init() should work properly both for iOS and Android.

Smartphone (please complete the following information):

ganchoradkov commented 1 year ago

hey @ClementeSerrano, could you confirm that your projectId is valid and that you're able to init signClient in browser env i.e. typescript so we can exclude possible isolated react-native issues?

clemente-xyz commented 1 year ago

hey @ClementeSerrano, could you confirm that your projectId is valid and that you're able to init signClient in browser env i.e. typescript so we can exclude possible isolated react-native issues?

Hi @ganchoradkov . Thanks for the fast reply. Yes, my projectId is valid (I generated it on WC dashboard and already double verified it).

The weird thing is that for iOS, without changing nothing in the code, works perfectly. It's only Android the issue

clemente-xyz commented 1 year ago

Our project is open source. You can see how we are implementing WC on our mobile app here.

In this file we init the SignClient and on this file we call the function that initialise it.

Then on this file we invoque the WC provider.

sapjax commented 1 year ago

same issue got these error:

 ERROR  {"context": "core"} undefined is not a function
 ERROR  {"context": "client"} undefined is not a function
glitch-txs commented 1 year ago

I’m closing this issue because it has been inactive for a few months.

Please reopen if you still encounter this issue with the latest version :)