khalti / khalti-sdk-android

SDK for Khalti Android App
23 stars 15 forks source link

Cannot find symbol Khalti.init when called from Java. #37

Closed therealyubraj closed 3 months ago

therealyubraj commented 3 months ago

When trying to call the init method of Khalti, I get cannot find symbol error.

         KhaltiPayConfig config = new KhaltiPayConfig(
                "public_key",
                "pidx_from_epayment_initiate",
                true,
                Environment.TEST
        );
        Khalti.init(ctx, config,
                // on payment result
                (paymentResult, khalti) -> {
                    Log.d("khalti", "On payment result");
                },
                // on message
                (payload, khalti) -> {
                    Log.d("khalti", "On message");
                },
                // on return
                (khalti) -> {
                    Log.d("khalti", "On return");
                }
        );

Reading the Kotlin doc for calling Kotlin static methods from java, @JvmStatic is required. Link to the doc.

Ishwor-Shrestha commented 3 months ago

Can you post the stacktrace and please provide a minimum reproducible code

Ishwor-Shrestha commented 3 months ago

How are you trying to invoke the init function? I can successfully invoke the function as follows:

Khalti.companion.init(...);
therealyubraj commented 3 months ago

I see. It seems the Khalti.Companion.init(...) does work. My bad, thanks a lot. @Ishwor-Shrestha