tolu360/react-native-paystack

Conflicts in okhttp versions in Paystack SDK and React Native 0.58+

nwaughachukwuma opened this issue ยท 23 comments

Hi @tolu360. Please this package breaks when building a React Native 0.58.x App with following errors
Could not resolve com.squareup.okhttp3:okhttp:3.12.1 required by react-native@0.58.x. Any plans to upgrade it?

A conflict between versions of dependencies between the underlying Paystack Android SDK and React Native could cause an issue like this. A workaround would be to add the following code block to the android/build.gradle file, just after allProjects.

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (!details.requested.name.contains('multidex')) {
                if (details.requested.group == 'com.android.support') {
                    details.useVersion "28.0.0"
                }

                if (details.requested.group == 'com.squareup.okhttp3') {
                    details.useVersion "3.12.1"
                }

                if (details.requested.group == 'com.squareup.okio') {
                    details.useVersion "1.15.0"
                }
            }
        }
    }
}

This solution also works for the newly released RN v0.59. I hope it helps!

Alright @christiandrey thanks so much

None of this working

Can someone help with this stuff

Can you please put up the actual error you're getting here? Might help in tracking down the issue. Thanks.

Hi @tolu360. Please this package breaks when building a React Native 0.58.x App with following errors
Could not resolve com.squareup.okhttp3:okhttp:3.12.1 required by react-native@0.58.x. Any plans to upgrade it?

exactly something like this

Can you show the contents of your root and app build.gradle files?

I think the problem could be that you're putting the code block in the wrong file. Please make sure you're putting that code just after allprojects in the root build.gradle file and not the app build.gradle file.
Here's a screenshot of my root build.gradle file.
image
image

i have put it in the exact location as you said bro, but the error changed to the above screenshot

Okay, this is a simpler error. You have this issue because the react-native-paystack library has specified its minSdkVersion as 19 while React Native, by default, specifies it as 16. The library also has specified android:allowBackup="true" in its AndroidManifest.xml while React Native has specified it by default as android:allowBackup="false". To fix, you should update your minSdkVersion, still in the root build.gradle file to 19 and set android:allowBackup="true" in your project's AndroidManifest. Instead, you can install the react-native-paystack from a fork I created where i fixed these last two issues in. Do npm install christiandrey/react-native-paystack or yarn add christiandrey/react-native-paystack, if you you use Yarn, to install from this fork.
Hope that helps!

AndroidManifest.
which folder can i locate this

because the one under android-src-main didnt work

Ideally, it should be the one in android/src/main. But if that's not working, you can try installing the package from the fork. It should be a better alternative. Please try that. Thanks!

worked ---
I had to set android:allowBackup="false" to 'true ' in the android/src/main . Hope it doesn't mean any security issue

No, it doesn't have any security implication.android:allowBackup only tells the system to include your app when a user is backing up their device.

i was able to compile and my emulator worked fine... Though i have not used any of the api, but great thanks for this.... @christiandrey you are the best..

Great stuff @christiandrey helping out today, cheers! If you added a feature you want me to know about in your fork, I would be happy to receive a PR.

@nkorojoseph glad you got stuff to work!

hi @tolu360 and @christiandrey, please can you help me with `chargeCard() {

RNPaystack.chargeCardWithAccessCode({
  cardNumber: '4123450131001381', 
  expiryMonth: '10', 
  expiryYear: '17', 
  cvc: '883',
  accessCode: '2p3j42th639duy4'
})
.then(response => {
  console.log(response); // do stuff with the token
})
.catch(error => {
  console.log(error); // error is a javascript Error object
  console.log(error.message);
  console.log(error.code);
})

}`
what this access code is and where to get it.

All these are detailed in the docs, read them carefully here. And if you have further issues unrelated to the conflict in okhttp library, I would recommend you open a new issue for those. Cheers

All these are detailed in the docs, read them carefully here. And if you have further issues unrelated to the conflict in okhttp library, I would recommend you open a new issue for those. Cheers

Ok, thanks....

Please see #38, follow the guides and only re-submit your issue if it persists thereafter. Cheers!