Sticky

React-Native / Expo Go: How to solve `TypeError: null is not an object (evaluating 'RNPurchases.setupPurchases')`

  • 29 August 2022
  • 4 replies
  • 2379 views

Userlevel 5
Badge +8
  • RevenueCat Staff
  • 236 replies

Expo Go doesn’t build native modules, so you may run into this error while trying to run your app with react-native-purchases in Expo Go. 

 

In order to use RevenueCat with Expo, you will have to create Development Builds, which can be done either by using EAS, or by making builds that are compatible with Xcode and Android Studio. 

There are detailed instructions for doing either one in this page:

https://docs.expo.dev/development/build/

 

Easiest way to be able to debug is to just run either of the following:

npx expo run:android -d

npx expo run:ios -d

 

We also have a blog post that goes step-by-step into how to make an app with Expo and RevenueCat using EAS: https://www.revenuecat.com/blog/in-app-puchase-expo-managed-workflow/

 

Let us know if you run into any issues! 


4 replies

Badge +4

this fixed the issue:
1) I imported the react native purchases 

2)I build a dev client build
 eas build --profile development --platform android

3) then launched the dev client
npx expo start --dev-client    

4)then opened it with the QR code and no more errorr

Badge +1

@Andy This makes sense for me  that I can only test IAP under a build development. But I would like to keep using my app testing in ExpoGo even if IAP are not working.

I tried to import conditionally the library but seems doesn't work that way in React Native

Any clue how can I keep debugging my app in ExpoGo? no matter if IAP doesn't work.

 

import { IsExpoGo, RevenueCatAPIKeys } from "./lib/constants";

if(!IsExpoGo){
import Purchases, { PurchasesOffering } from 'react-native-purchases';
}
Badge +4

nat-serrano@Nats-MacBook-Pro-2 Maxine % npx expo run:android -d

env: load .env
env: export EXPO_PUBLIC_11LABS_API_KEY EXPO_PUBLIC_SD_URL EXPO_PUBLIC_LLM_URL EXPO_PUBLIC_RC_ANDROID_KEY EXPO_PUBLIC_RC_IOS_KEY
✔ Select a device/emulator › Pixel_6_Pro_API_34 (emulator)
› Using --device Pixel_6_Pro_API_34
› Building app...
Configuration on demand is an incubating feature.

> Configure project :app
 ℹ️  Applying gradle plugin 'expo-dev-launcher-gradle-plugin' (expo-dev-launcher@3.6.6)

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not determine the dependencies of null.
   > SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/nat-serrano/Desktop/Maxine/android/local.properties'.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 4s
10 actionable tasks: 10 up-to-date
Error: /Users/nat-serrano/Desktop/Maxine/android/gradlew exited with non-zero code: 1
Error: /Users/nat-serrano/Desktop/Maxine/android/gradlew exited with non-zero code: 1
    at ChildProcess.completionListener (/Users/nat-serrano/Desktop/Maxine/node_modules/@expo/cli/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
    at Object.onceWrapper (node:events:633:26)
    at ChildProcess.emit (node:events:518:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
    ...
    at Object.spawnAsync [as default] (/Users/nat-serrano/Desktop/Maxine/node_modules/@expo/cli/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
    at spawnGradleAsync (/Users/nat-serrano/Desktop/Maxin/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:72:46)
    at Object.assembleAsync (/Users/nat-serrano/Desktop/Maxine/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:52:18)
    at runAndroidAsync (/Users/nat-serrano/Desktop/Maxine/node_modules/@expo/cli/build/src/run/android/runAndroidAsync.js:36:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Badge +4

@Alejandro Did you ever find a solution to this?

Reply