paypal / android-checkout-sdk

Apache License 2.0
77 stars 38 forks source link

Method 'void com.paypal.pyplcheckout.di.DaggerSdkComponent$Factory.<init>()' is inaccessible to class 'com.paypal.pyplcheckout.di.DaggerSdkComponent' (declaration of 'com.paypal.pyplcheckout.di.DaggerSdkComponent' appears in /data/app/com.marineonline.app-NDFpNmA3WJVGGLKMNiiphA==/base.apk!classes4.dex) #292

Closed StationChnqoo closed 10 months ago

StationChnqoo commented 10 months ago

Before you create a new issue, please search for similar issues. It's possible somebody has encountered this bug already. PLEASE REMOVE THIS LINE TO ACKNOWLEDGE THAT AN ISSUE DOESN'T ALREADY EXIST FOR THIS BUG

Describe the bug I'm using com.paypal.checkout:android-sdk:1.2.1in React Native project. I got this exception:

FATAL EXCEPTION: main
  Process: com.marineonline.app, PID: 23263
  java.lang.IllegalAccessError: Method 'void com.paypal.pyplcheckout.di.DaggerSdkComponent$Factory.<init>()' is inaccessible to class 'com.paypal.pyplcheckout.di.DaggerSdkComponent' (declaration of 'com.paypal.pyplcheckout.di.DaggerSdkComponent' appears in /data/app/com.marineonline.app-NDFpNmA3WJVGGLKMNiiphA==/base.apk!classes4.dex)
    at com.paypal.pyplcheckout.di.DaggerSdkComponent.factory(DaggerSdkComponent.java:760)
    at com.paypal.pyplcheckout.di.SdkComponent$Companion.create(SdkComponent.kt:162)
    at com.paypal.checkout.PayPalCheckout.setConfig(PayPalCheckout.kt:52)
    at com.emarineonline.marineonline.MainApplication.initPaypalConfigs(MainApplication.java:167)
    at com.emarineonline.marineonline.MainApplication.onCreate(MainApplication.java:144)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6582)
    at android.app.ActivityThread.access$1400(ActivityThread.java:224)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:224)
    at android.app.ActivityThread.main(ActivityThread.java:7562)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

To Reproduce

ext {
    compileSdkVersion = 31
    targetSdkVersion = 31
    minSdkVersion = 21
    buildToolsVersion = "31.0.0"
    googlePlayServicesVersion = "15.0.1"
    supportLibVersion = "30.0.0"
}

Here is my code in MainApplication.java:

public class MainApplication extends Application implements ReactApplication {

    private static MainApplication instance;

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

    public static Application getInstance(){
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        initPaypalConfigs();
        SoLoader.init(this, /* native exopackage */ false);
    }

    private void initPaypalConfigs() {
        // https://developer.paypal.com/limited-release/paypal-mobile-checkout/initialize-sdk/
        CheckoutConfig config = new CheckoutConfig(
            MainApplication.getInstance(),
            "my-client-id",
            Environment.SANDBOX,
            CurrencyCode.USD,
            UserAction.PAY_NOW,
            PaymentButtonIntent.CAPTURE,
            new SettingsConfig(
                true,
                false
            ),
            new UIConfig(true),
            "my-package-id://paypalpay"
        );
        PayPalCheckout.setConfig(config);
    }
}

Expected behavior Config successfully.

Screenshots

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

github-actions[bot] commented 10 months ago

Thank you for reaching out to the Native Checkout SDK team. This integration path is now inactive for new merchants. If you are an existing merchant, please contact us here for further assistance.

New merchants can integrate the Native Checkout experience via the Braintree Android SDK or PayPal Android SDK. For more information please see their respective developer documentation linked below.

StationChnqoo commented 10 months ago

很高兴的告诉各位developer,这个问题已经解决了。 因为目前的项目是ReactNative两年前的版本,所以这中间会涉及到很多三方库的升级和兼容性问题。经过排查新建一个新的Project是没问题的,所以结论是目前的配置有问题。 我尝试依次升级了以下配置:

希望对遇见同样问题的各位有所帮助和启示😄