reown-com / reown-kotlin

Apache License 2.0
12 stars 4 forks source link

Error during WalletKit initialization: TimeoutCancellationException: Timed out waiting for 10000 ms #19

Closed ShengXiuyan closed 4 weeks ago

ShengXiuyan commented 1 month ago

I'm using the reown-kotlin library in my Android project with the following dependencies in my build.gradle:

implementation(platform("com.reown:android-bom:1.0.0"))
implementation("com.reown:android-core")
implementation("com.reown:walletkit")

Here is my code:

CoreClient.initialize(
    application = this,
    projectId = projectId,
    connectionType = ConnectionType.AUTOMATIC,
    metaData = getAppMetaData(),
    onError = { error ->
        // Error handling
    }
)
WalletKit.initialize(
    Wallet.Params.Init(core = CoreClient),
    onSuccess = {

    },
    onError = {
        //Error(throwable=kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 10000 ms)
    }
)

When trying to initialize WalletKit, I get the following error: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 10000 ms

I followed the documentation here: https://docs.reown.com/walletkit/android/usage, but the error occurs every time I call WalletKit.initialize. Are there any known causes of this issue or potential solutions?

jakubuid commented 1 month ago

Hey! What's the application that you're passing? Where do you initialize the SDK? In the Application class?

ShengXiuyan commented 1 month ago

Hi! Yes, I'm using MyApplication : Application() for SDK initialization. If I use the following dependencies:

implementation(platform("com.reown:android-bom:1.0.0"))
implementation("com.reown:android-core")
implementation("com.reown:sign")

and initialize like this:

MyApplication : Application() {
    CoreClient.initialize(
        relayServerUrl = serverUrl,
        connectionType = connectionType,
        application = this,
        metaData = getAppMetaData()
    ) { throwable ->
        // Error handling
    }

    SignClient.initialize(
        Sign.Params.Init(core = CoreClient),
        onSuccess = {},
        onError = {}
    )
}

everything works as expected. But if I switch to these dependencies:

implementation(platform("com.reown:android-bom:1.0.0"))
implementation("com.reown:android-core")
implementation("com.reown:walletkit")

and use this initialization:

CoreClient.initialize(
    application = this,
    projectId = projectId,
    connectionType = ConnectionType.AUTOMATIC,
    metaData = getAppMetaData(),
    onError = { error ->
        // Error handling
    }
)

WalletKit.initialize(
    Wallet.Params.Init(core = CoreClient),
    onSuccess = {
        // Success handling
    },
    onError = {
        // Error handling
        //Error(throwable=kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 10000 ms)
    }
)

I encounter this error: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 10000 ms

I hope this information will be helpful in identifying the cause of the issue.

jakubuid commented 4 weeks ago

Thanks for providing more details, unfortunately, I cannot reproduce it. Could you check our Kotlin Sample Wallet as a reference integration? See: https://github.com/reown-com/reown-kotlin/blob/develop/sample/wallet/src/main/kotlin/com/reown/sample/wallet/WalletKitApplication.kt#L74

jakubuid commented 4 weeks ago

This issue is resolved in this PR