razorpay / razorpay-android-custom-sample-app

Sample app to demonstrate the custom UI integration
MIT License
13 stars 9 forks source link

Getting crash on release app build #51

Closed ravisharma46 closed 3 years ago

ravisharma46 commented 3 years ago

Fatal Exception: java.lang.NoClassDefFoundError Failed resolution of: Lcom/razorpay/K;

Caused by java.lang.ClassNotFoundException: com.razorpay.K at com.razorpay.BaseConfig.getAdvertisingId(BaseConfig.java:436) at com.razorpay.BaseConfig.getAdvertisingIdFromUtil(BaseConfig.java:323) at com.razorpay.BaseRazorpay.initRazorpay(BaseRazorpay.java:167) at com.razorpay.BaseRazorpay.(BaseRazorpay.java:154) at com.razorpay.OtpelfBaseRazorpay.(OtpelfBaseRazorpay.java:15) at com.razorpay.Razorpay.(Razorpay.java:46) at com.inventia.app.ui.activities.PaymentActivity.initRazorpay(PaymentActivity.java:378) at com.inventia.app.ui.activities.PaymentActivity.onCreate(PaymentActivity.java:115) at android.app.Activity.performCreate(Activity.java:7963) at android.app.Activity.performCreate(Activity.java:7952) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3505) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3689) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:140) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:100) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2239) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:227) at android.app.ActivityThread.main(ActivityThread.java:7822) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026)

ravisharma46 commented 3 years ago

@vivekshindhe @vivekagarwal1984 @sumedht Please help.

vivekshindhe commented 3 years ago

@ravisharma46 not able to reproduce this on our end. Please ensure the following points are ticked from your side,

-keepclassmembers class * { @android.webkit.JavascriptInterface ; }

-keepattributes JavascriptInterface -keepattributes Annotation

-dontwarn com.razorpay. -keep class com.razorpay. {*;}

-optimizations !method/inlining/*

-keepclasseswithmembers class { public void onPayment(...); }

Please check if these are true. This should solve the issue.

ravisharma46 commented 3 years ago

Yes i am using the same in my proguard file

-keepclassmembers class * { @android.webkit.JavascriptInterface ; }

-keepattributes JavascriptInterface -keepattributes Annotation

-dontwarn com.razorpay. -keep class com.razorpay. {*;}

-optimizations !method/inlining/*

-keepclasseswithmembers class { public void onPayment(...); }

ravisharma46 commented 3 years ago

@vivekshindhe Please check this out

vivekshindhe commented 3 years ago

How are you generating your release build?

ravisharma46 commented 3 years ago

@vivekshindhe I am generating signed APK threw android studio

vivekshindhe commented 3 years ago

@ravisharma46 What payment are you attempting? At what stage does this happen? A video would be helpful too. Also, I've updated this git repo with branch v3.9.3. This has my implementation of this, and a release build with custom-checkout v3.9.3. Could you please also try that?

ravisharma46 commented 3 years ago

https://drive.google.com/file/d/1PLaRr2jn1C3tYu3rZxG1eUkPoS6A8EEa/view?usp=sharing

After clicking on buy button a checkout page should be open but i am getting crash on buy now button click. Please find the video i have shared link @vivekshindhe

vivekshindhe commented 3 years ago

@ravisharma46 You are using custom checkout right? There won't be a checkout page. I didn't understand that part. Could you please clarify?

ravisharma46 commented 3 years ago

@vivekshindhe yes i am using custom check out page.

razorpay = new Razorpay(this, Constants.RAZORPAY_KEY); razorpay.getPaymentMethods(new PaymentMethodsCallback() { @Override public void onPaymentMethodsReceived(String result) { inflateLists(result); }

        @Override
        public void onError(String s) {
            FirebaseCrashlytics.getInstance().recordException(new Exception("Reading Payments methods  " + s));
        }
    });

Here is the code in my payment activity..I am getting crash when i am fetching all payment methods. the crash i have shared in first comment.

vivekshindhe commented 3 years ago

Would it be possible for you to share the build you are testing this on? You can also share it to my mail, vivek.shindhe@razorpay.com. If possible. Or you could manually check for the existence of the class com.razorpay.K by analysing the apk. If it doesn't exist this will have something to do with proguard.

ravisharma46 commented 3 years ago

ok i am sharing you a release build on your mail.

ravisharma46 commented 3 years ago

@vivekshindhe have shared APK on your email.

vivekshindhe commented 3 years ago

I can see the file. Will need to deep dive on this. Until then please check the branch v3.9.3 in the repo.

ravisharma46 commented 3 years ago

@vivekshindhe keeping this in release build mode it is working. could you please check. release { debuggable true FirebasePerformance { instrumentationEnabled false } }

vivekshindhe commented 3 years ago

@ravisharma46 thanks for update. Do you use R8? Also if possible can you add -dontusemixedcaseclassnames to your proguard? This seems to be an issue due to Firebaseperformance doing the obfuscation. Here's the github ticket on the issue from firebase repo https://github.com/firebase/firebase-android-sdk/issues/1476#issuecomment-625177988. Please let me know if this works.

ravisharma46 commented 3 years ago

I have to update the firebase performance plugin. Now, it is working very fine.

Thank you very much for the fast response @vivekshindhe

vivekshindhe commented 3 years ago

@ravisharma46 awesome news. Thanks for reaching out to us. Closing the ticket now.