WalletConnect / WalletConnectKotlinV2

WalletConnect Kotlin SDK v2
Apache License 2.0
251 stars 83 forks source link

Crash on calling Web3ModalComponent Composable - org.koin.core.error.NoBeanDefFoundException Web3ModalEngine #1413

Open Raenar4k opened 5 months ago

Raenar4k commented 5 months ago

Describe the bug

Crash when we are calling Web3ModalComponent composable function:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:562)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878) 
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
...
    at androidx.lifecycle.viewmodel.compose.ViewModelKt__ViewModelKt.viewModel(ViewModel.kt:103)
    at androidx.lifecycle.viewmodel.compose.ViewModelKt.viewModel(Unknown Source:1)
    at com.walletconnect.web3.modal.ui.components.internal.Web3ModalComponentKt.Web3ModalComponent(Web3ModalComponent.kt:122)
    at com.walletconnect.web3.modal.ui.components.internal.Web3ModalComponentKt.Web3ModalComponent(Web3ModalComponent.kt:40)
...
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
...
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8501)
    ... 3 more
Caused by: org.koin.core.error.NoBeanDefFoundException: No definition found for type 'com.walletconnect.web3.modal.engine.Web3ModalEngine'. Check your Modules configuration and add missing type and/or qualifier!
    at org.koin.core.scope.Scope.throwDefinitionNotFound(Scope.kt:302)
    at org.koin.core.scope.Scope.resolveValue(Scope.kt:272)
    at org.koin.core.scope.Scope.resolveInstance(Scope.kt:234)
    at org.koin.core.scope.Scope.get(Scope.kt:213)
    at com.walletconnect.web3.modal.ui.Web3ModalViewModel.<init>(Web3ModalViewModel.kt:47)
    ... 114 more

SDK Version

To Reproduce Steps to reproduce the behavior:

  1. Call Web3ModalComponent in compose code.

Expected behavior Compose function works correctly, we get a WC modal UI

jakubuid commented 1 month ago

Hello, I'll take a look into this shortly, thanks

jakubuid commented 1 month ago

@Raenar4k can you check if you have android:name tag in your Manifest file?

Raenar4k commented 1 month ago

@jakubuid What do you mean? android:name attribute can be used in multiple places. Yes, we use it for our application, activity, service, provider and other places too. Im not sure where should i be looking and how it is connected to koin crash

jakubuid commented 1 month ago

Hey, I meant in AndroidManifest. I was able to reproduce and fix by setting this in AndroidManifest of my sample app

Raenar4k commented 1 month ago

As you can see, we have 23 of these attributes in our AndroidManifest file.

image

Which xml tag with this attribute affects Koin?

    <application
        android:name=".App"
        <activity
            android:windowSoftInputMode="adjustResize"
            android:name="com.test.app.AppActivity"
        <service
            android:name=".feature.push.FirebasePushService"
        <provider
            android:name="androidx.core.content.FileProvider"
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

There are others but i doubt they are relevant