Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nwaughachukwuma opened this issue Mar 1, 2019 · 23 comments
Closed

Comments

@nwaughachukwuma
Copy link

nwaughachukwuma commented Mar 1, 2019

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 [email protected]. Any plans to upgrade it?

@christiandrey
Copy link

christiandrey commented Mar 14, 2019

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!

@nwaughachukwuma
Copy link
Author

Alright @christiandrey thanks so much

@nkorojoseph
Copy link

None of this working

@nkorojoseph
Copy link

Can someone help with this stuff

@christiandrey
Copy link

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

@nkorojoseph
Copy link

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 [email protected]. Any plans to upgrade it?

exactly something like this

@nkorojoseph
Copy link

image

@nwaughachukwuma
Copy link
Author

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

@christiandrey
Copy link

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

@nkorojoseph
Copy link

image
image

@nkorojoseph
Copy link

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

@christiandrey
Copy link

christiandrey commented May 16, 2019

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!

@nkorojoseph
Copy link

AndroidManifest.
which folder can i locate this

@nkorojoseph
Copy link

because the one under android-src-main didnt work

@christiandrey
Copy link

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!

@nkorojoseph
Copy link

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

@christiandrey
Copy link

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.

@nkorojoseph
Copy link

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..

@tolu360
Copy link
Owner

tolu360 commented May 16, 2019

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!

@tolu360 tolu360 changed the title Upgrade to support React Native 0.58.x Conflicts in okhttp versions in Paystack SDK and React Native 0.58+ May 16, 2019
@nkorojoseph
Copy link

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.

@tolu360
Copy link
Owner

tolu360 commented May 17, 2019

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

@nkorojoseph
Copy link

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....

@tolu360
Copy link
Owner

tolu360 commented Sep 4, 2019

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

@tolu360 tolu360 closed this as completed Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants