Solved

null is not an object (evaluating 'RNPurchases.setDebugLogsEnabled')


Badge +2

I installed the expo managed workflow and also followed the revenuecat/react-native-purchases guide and trying a simple code to setDebugLogs I keep getting 
 

 React.useEffect(() => {
Purchases.setDebugLogsEnabled(true);
}, []);

null is not an object (evaluating 'RNPurchases.setDebugLogsEnabled')

 

I also tried a simple configure and got similar issue

 React.useEffect(() => {
Purchases.configure({apiKey:"xxxxxxxxx"});
}, []);

null is not an object (evaluating 'RNPurchases.setPurchases')

 

Any idea what could it be or how to debug this?

I read other comments and issues but none of them had a working solution

 

Note: I started trying this today so I have the latest versions of everything, expo, react native and react native purchases

icon

Best answer by MarcosC 26 August 2022, 21:07

View original

12 replies

Userlevel 3
Badge +6

Hi @crediswap 

I’m not an expert on expo, but I was playing with expo today for the first time and I was having the same issue as you described. After adding a development build (https://docs.expo.dev/development/build/) I stopped having the issue. Is that something you can try?

 

Regards,

Marcos

Userlevel 5
Badge +8

Like Marcos mentioned, you’ll have to make sure create a development build. 

This can be done either through EAS or with Xcode / Android Studio. 

 

Here are the docs for it:

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

Badge +2

Do you guys mean that I can only test it through development builds (generate the dev build and then download the build in the device to test), not running locally?

Userlevel 5
Badge +8

@crediswap you should still be able to test locally. Instructions are in the second section of the page I linked previously, here: https://docs.expo.dev/development/build/#locally-with-xcode-and-android-studio

 

Basically you’d run: 

expo run:android -d or expo run:ios -d

Badge +2

Thanks, the null issue was fixed, now I’m getting empty list of products and everything seems fine, I’ve followed the thread here but no luck:
 


 

{
"expo": {
"name": "crediswap",
"slug": "crediswap",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "myapp",
"userInterfaceStyle": "automatic",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"versionCode": 2,
"package": "com.crediswap.crediswap",
"permissions": [
"com.android.vending.BILLING"
],
"adaptiveIcon": {
"foregroundImage": "./assets/images/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"web": {
"favicon": "./assets/images/favicon.png"
},
"extra": {
"eas": {
"projectId": "0ee5007a-6158-4009-8d6a-72bc1cff029d"
}
}
}
}



Any ideas? This is the sample code:

export default function Products() {
const [product, setproduct] = useState<PurchasesProduct | null>(null);

useEffect(() => {
try{
const fetchData = async () => {
const products = await Purchases.getProducts(["test_coupom_1"]);
console.log(products)
setproduct(products[0] || null)
};

Purchases.setDebugLogsEnabled(true);
Purchases.setup(APIKeys.google);

fetchData()
} catch (error) {
console.log(error)
}
}, []);

if (!product) {
return <Text>"Loading..."</Text>;
} else {
return (
<View>
<Text>Identifier: {product.identifier}</Text>
<Text>Title: {product.title}</Text>
<Text>Description: {product.description}</Text>
<Text>Price: {product.price}</Text>
</View>
);
}
}

All I get is  this:
Array []

Btw, any way I can better debug it? I tried setting the debugging mode but still I don’t get anything when running the server
 

Userlevel 5
Badge +8

In order to see the debug logs, you need to go into Android Studio, and then Logcat (near the bottom). 

 

Those logs should help us figure out what’s going on

Badge +2
2022-08-30 20:44:24.710 8209-22767/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Debug logging enabled
2022-08-30 20:44:24.711 8209-22767/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ SDK Version - 4.6.1
2022-08-30 20:44:24.711 8209-22767/com.crediswap.crediswap D/[Purchases] - DEBUG: 👤 Initial App User ID - null
2022-08-30 20:44:24.711 8209-22767/com.crediswap.crediswap D/[Purchases] - DEBUG: 👤 Identifying App User ID: $RCAnonymousID:36244bb505c14d0c8f5accb0d5a7f8a0
2022-08-30 20:44:24.713 8209-22767/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Deleting old synced subscriber attributes that don't belong to $RCAnonymousID:36244bb505c14d0c8f5accb0d5a7f8a0
2022-08-30 20:44:24.714 8209-22767/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Listener set
2022-08-30 20:44:24.714 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ App foregrounded
2022-08-30 20:44:24.714 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ PurchaserInfo cache is stale, updating from network in foreground.
2022-08-30 20:44:24.714 8209-22767/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Sending latest PurchaserInfo to listener.
2022-08-30 20:44:24.716 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Offerings cache is stale, updating from network in foreground
2022-08-30 20:44:24.716 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: 😻 Offerings updated from network.
2022-08-30 20:44:24.717 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Skipping updating pending purchase queue since BillingClient is not connected yet.
2022-08-30 20:44:24.717 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ No subscriber attributes to synchronize.
2022-08-30 20:44:24.719 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Starting connection for com.android.billingclient.api.BillingClientImpl@f0ee011
2022-08-30 20:44:24.721 8209-22856/com.crediswap.crediswap D/TrafficStats: tagSocket(117) with statsTag=0xffffffff, statsUid=-1
2022-08-30 20:44:24.722 8209-22767/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Requesting products from the store with identifiers: test_coupom_1
2022-08-30 20:44:24.722 8209-22788/com.crediswap.crediswap D/TrafficStats: tagSocket(119) with statsTag=0xffffffff, statsUid=-1
2022-08-30 20:44:24.749 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Starting connection for com.android.billingclient.api.BillingClientImpl@f0ee011
2022-08-30 20:44:24.749 8209-8209/com.crediswap.crediswap W/BillingClient: Client is already in the process of connecting to billing service.
2022-08-30 20:44:24.835 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Billing Service Setup finished for com.android.billingclient.api.BillingClientImpl@f0ee011
2022-08-30 20:44:24.835 8209-8209/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Updating pending purchase queue
2022-08-30 20:44:25.198 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ API request started: GET /subscribers/%24RCAnonymousID%3A36244bb505c14d0c8f5accb0d5a7f8a0
2022-08-30 20:44:25.199 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ API request completed with status: GET /subscribers/%24RCAnonymousID%3A36244bb505c14d0c8f5accb0d5a7f8a0 304
2022-08-30 20:44:25.202 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ PurchaserInfo updated, sending to listener.
2022-08-30 20:44:25.250 8209-22868/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Products request finished for test_coupom_1
2022-08-30 20:44:25.250 8209-22868/com.crediswap.crediswap D/[Purchases] - DEBUG: 💰 Retrieved skuDetailsList:
2022-08-30 20:44:25.263 8209-22766/com.crediswap.crediswap I/ReactNativeJS: []
2022-08-30 20:44:25.267 8209-22766/com.crediswap.crediswap I/ReactNativeJS: finish products
2022-08-30 20:44:25.323 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ API request started: GET /subscribers/%24RCAnonymousID%3A36244bb505c14d0c8f5accb0d5a7f8a0/offerings
2022-08-30 20:44:25.323 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ API request completed with status: GET /subscribers/%24RCAnonymousID%3A36244bb505c14d0c8f5accb0d5a7f8a0/offerings 304
2022-08-30 20:44:25.324 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ SKU list is empty, skipping querySkuDetailsAsync call
2022-08-30 20:44:25.325 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Querying purchases
2022-08-30 20:44:25.336 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Cleaning previously sent tokens
2022-08-30 20:44:25.336 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Tokens already posted: []
2022-08-30 20:44:25.336 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Saving tokens []
2022-08-30 20:44:25.337 8209-22856/com.crediswap.crediswap D/[Purchases] - DEBUG: ℹ️ Tokens already posted: []

 

I also got this when filtering by error only:

2022-08-30 20:44:02.434 8209-8209/com.crediswap.crediswap E/unknown:ReactNative: Tried to remove non-existent frame callback
2022-08-30 20:44:02.442 8209-8209/com.crediswap.crediswap E/unknown:ReactInstanceManager: destroyRootView called
2022-08-30 20:44:02.442 8209-8209/com.crediswap.crediswap E/unknown:ReactInstanceManager: destroyRootView called, unmountReactApplication
2022-08-30 20:44:02.718 8209-8417/com.crediswap.crediswap E/[Purchases] - ERROR: 😿‼️ Error performing request.
2022-08-30 20:44:02.718 8209-8417/com.crediswap.crediswap E/Purchases: Error fetching subscriber data: Error performing request.

 

Userlevel 5
Badge +8

It looks like the SDK is requesting “test_coupom_1”, but it’s not getting returned by Google Play. Could you make sure that the product with that identifier is set up correctly in Google Play, is active, and at least 36 hours have passed since it was activated? 

Badge +2

yeah I’ve double checked all that :(

 

 

 

Badge +2

So apparently it is not in Revenuecat side, right? It seems google configuration issue, even though I’ve checked all the most common issues and everything seems correct

Badge +2

I’ll mark this one as fixed and open a new thread

Badge +2

 

Reply