通过将B作为库模块导入,我将两个应用程序A和B合并为一个。应用程序A具有Razorpay集成。在合并应用程序之前,razorpay工作正常,但在合并后显示com.razorpay.checkout活动未发现异常。

我通过从gradle启用proguard规则。我也将razorpay库版本升级到1.5.5。但是仍然无法正常工作。

public void startPayment() {
        /*
          You need to pass current activity in order to let Razorpay create CheckoutActivity
         */
        /*
          You need to pass current activity in order to let Razorpay create CheckoutActivity
         */
            final Checkout co = new Checkout();
            co.setImage(R.drawable.kdgologo);

        final Activity activity = this;


        int amount= Integer.parseInt(amountget);

        try {
            JSONObject options = new JSONObject();
            options.put("name", customer_idget);
            options.put("description", orderIdget);
            //You can omit the image option to fetch the image from dashboard
            options.put("image", "https://s3.amazonaws.com/rzp-mobile/images/rzp.png");
            options.put("currency", "INR");
            options.put("amount", amount*100);

            JSONObject preFill = new JSONObject();
            preFill.put("email", emailget);
            preFill.put("contact", cnumberget);

            options.put("prefill", preFill);

            JSONObject notes = new JSONObject();
            notes.put("opencart_order_id", orderIdget);
            options.put("notes",notes);

            co.open(activity, options);
        } catch (Exception e) {
            Toast.makeText(activity, "Error in payment: " + e.getMessage(), Toast.LENGTH_SHORT)
                    .show();
            e.printStackTrace();
        }
}


错误信息:

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.kdgo.in/com.razorpay.CheckoutActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1777)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1618)
at android.app.Activity.startActivityFromFragment(Activity.java:4392)
at android.app.Fragment.startActivityForResult(Fragment.java:1100)
at android.app.Fragment.startActivityForResult(Fragment.java:1084)
at com.razorpay.Checkout.onCreate(:302)
at android.app.Fragment.performCreate(Fragment.java:2031)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:863)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.app.BackStackRecord.run(BackStackRecord.java:834)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)

最佳答案

通过将B作为库模块导入,我将两个应用程序A和B合并为一个。应用程序A具有Razorpay集成。在合并应用程序之前,razorpay工作正常,但在合并后显示com.razorpay.checkout活动未发现异常


将项目集成为模块时的主要问题是忘记将库包含到主应用程序module中。这主要是因为我们将implementation用于依赖项。

您可以将库模块中的依赖项从implementation更改为api。或者,您可以将依赖项行复制到主应用程序模块。

07-27 22:11