I am working on a Flutter app. In this app I am integrating Adyen payment gateway. To achieve this I have created a separate plugin to handle encrypting the card and other api calls to Adyen. In this process I have implemented encryptCard method from Adyen Android SDK.

I am facing following error when I am trying to use encrypt:

E/AndroidRuntime(31103): FATAL EXCEPTION: main E/AndroidRuntime(31103): Process: com.mycompany.my_mobile, PID: 31103 E/AndroidRuntime(31103): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/adyen/checkout/card/util/CardValidationUtils; E/AndroidRuntime(31103): at group.mycompany.adyen_payment.AdyenPaymentPlugin.validateCardNumber(AdyenPaymentPlugin.kt:85) E/AndroidRuntime(31103): at group.mycompany.adyen_payment.AdyenPaymentPlugin.onMethodCall(AdyenPaymentPlugin.kt:38) E/AndroidRuntime(31103): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267) E/AndroidRuntime(31103): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/AndroidRuntime(31103): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/AndroidRuntime(31103): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/AndroidRuntime(31103): at android.os.Handler.handleCallback(Handler.java:958) E/AndroidRuntime(31103): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(31103): at android.os.Looper.loopOnce(Looper.java:205) E/AndroidRuntime(31103): at android.os.Looper.loop(Looper.java:294) E/AndroidRuntime(31103): at android.app.ActivityThread.main(ActivityThread.java:8177) E/AndroidRuntime(31103): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(31103): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) E/AndroidRuntime(31103): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) E/AndroidRuntime(31103): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.adyen.checkout.card.util.CardValidationUtils" on path: DexPathList[[zip file "/data/app/~~rCuroo2Bbmn6AQLg2tVGAg==/com.mycompany.my_mobile-gZQNg2av6NcxnGdFFX1knQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~rCuroo2Bbmn6AQLg2tVGAg==/com.mycompany.my_mobile-gZQNg2av6NcxnGdFFX1knQ==/lib/arm64, /data/app/~~rCuroo2Bbmn6AQLg2tVGAg==/com.mycompany.my_mobile-gZQNg2av6NcxnGdFFX1knQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]] E/AndroidRuntime(31103): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259) E/AndroidRuntime(31103): at java.lang.ClassLoader.loadClass(ClassLoader.java:379) E/AndroidRuntime(31103): at java.lang.ClassLoader.loadClass(ClassLoader.java:312) E/AndroidRuntime(31103): ... 14 more I/Process (31103): Sending signal. PID: 31103 SIG: 9 Lost connection to device. the Dart compiler exited unexpectedly.

I have following method in PaymentPlugin.kt file:

private fun encryptCVV(
        call: MethodCall, result: MethodChannel.Result
    ) {
        val resultData = JSONObject()
        try {
            val encryptionKey: String? = MY_ENCRYPTION_KEY
            val cvv: String? = call.argument("securityCode")

            val rawCard: UnencryptedCard = UnencryptedCard.Builder().setCvc(cvv!!).build()

            val encryptedCard: EncryptedCard = CardEncrypter.encryptFields(rawCard, encryptionKey!!)
            resultData.put("encryptedCVV", encryptedCard.encryptedSecurityCode)

        } catch (e: Exception) {
            resultData.put("error", e.message)
        }
        result.success(resultData.toString())
    }


I tried to change min sdk version.