Search code examples
reactjsin-app-billingreact-native

Issues with In-app-billing on React Native


I'm implementing In-app-billing on my React Native project using this. https://github.com/idehub/react-native-billing

This is the code I'm using.

InAppBilling.open()
.then(() => InAppBilling.purchase('android.test.purchased'))
.then((details) => {
  console.log("You purchased: ", details)
  return InAppBilling.close()
});

and I got this error.

enter image description here

Can anyone help me with the solution? Thanks in advance.


Solution

  • This from the GitHub issue:

    "Easiest way is to run react-native link react-native-billing after npm install --save react-native-billing. That will add the native build config for you. The link command will be adding the native config, and you do not have to follow the manual installation.

    But your build.gradle should not contain com.anjlab.android.iab.v3 since that is added by this module in another file. Yours should instead have something like compile project(':react-native-billing')."

    After making a change like this I always run these in the terminal to reset everything and then refresh the app afterwards:

    watchman watch-del-all

    node_modules/react-native/packager/packager.sh --reset-cache