expo
expo copied to clipboard
[SDK45] [Expo In App Purchases] [Android] Error: When Using purchaseItemAsync methods
Summary
After updating the expo sdk from 44 to 45, I am getting the following error in the purchase process. I am not sure if it is directly related to the SDK, but I am having trouble because the error code does not bring up any research. Could you please advise?
My codes
export const purchaseProducts = async (productId: string) => {
try {
await purchaseItemAsync(productId);
} catch (error) {
console.log(error);
}
};
My error code is here.
[Error: Encountered an exception while calling native method: Exception occurred while executing exported method purchaseItemAsync on module ExpoInAppPurchases: Attempt to invoke interface method 'java.lang.String expo.modules.core.arguments.ReadableArguments.getString(java.lang.String)' on a null object reference]
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
bare
What platform(s) does this occur on?
Android
Environment
expo-env-info 1.0.3 environment info:
System:
OS: macOS 12.2.1
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.0 - ~/.nodebrew/current/bin/node
Yarn: 1.22.17 - ~/.nodebrew/current/bin/yarn
npm: 8.1.0 - ~/.nodebrew/current/bin/npm
Watchman: 2022.03.21.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /Users/ken/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 27, 28, 29, 30, 31, 32
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 31.0.0, 33.0.0
System Images: android-30 | Google Play Intel x86 Atom
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.6953283
Xcode: 13.4/13F17a - /usr/bin/xcodebuild
npmPackages:
babel-preset-expo: ~9.1.0 => 9.1.0
expo: ^45.0.0 => 45.0.3
react: 17.0.2 => 17.0.2
react-dom: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-web: 0.17.7 => 0.17.7
react-navigation: ^4.4.4 => 4.4.4
npmGlobalPackages:
eas-cli: 0.52.0
expo-cli: 5.4.6
Expo Workflow: bare
Reproducible demo
Not sure how this can be replicated.
I have the same problem on android. The Expo SDK version is 45. (expo-in-app-purchase: 13.0.0)
Perhaps I found the reason. It is because the details
argument for Android in expo-in-app-purchase v13.
https://docs.expo.dev/versions/latest/sdk/in-app-purchases/#inapppurchasespurchaseitemasyncitemid-details
Note: both ids must be provided for payments to work on Google Play.
struggling with the same thing, expo/react-native docs does not seem to mention how we can get it for Android users
The following explanation of obfuscatedAccountid and obfuscatedProfileId is helpful. https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder?hl=ja#setObfuscatedAccountId(java.lang.String)
This is a mechanism to prevent fraud, but I don't think this setting should be mandatory because it is unnecessary for apps that only offer non-consumable charges 🤔
struggling with the same thing, expo/react-native docs does not seem to mention how we can get it for Android users
The docs posted by @gaishimo indicate that these ids are up to the implementor to provide. Empty strings would technically work (as @lottemarines posted), but to avoid future regret that might arise from passing garbage into those parameters we decided to run the user id from our system through md5 and use that. If you don't have a user id from your own system maybe empty strings is the way to go (until this issue is fixed).
up, having same problem with expo-in-app-purchases 13.0.0 version and expo sdk 45
Passing empty string is working as it should be.
Passing empty string is working as it should be.
for me too!
Still experience this with expo-in-app-purchases 13.1.0. Has this fix been released? If not, please release it ASAP. Thank you so much
is there any progress going on?
The fix in https://github.com/expo/expo/pull/18272 will be released with the next SDK (SDK 47) coming this fall.
Is there any more detailed schedule or maybe even beta?
There will be a beta but I don't think there is yet a date announced. When the beta is available it will be announced on blog.expo.dev.
In 13.1.0, you can avoid this error by passing details
argument forcibly.
await purchaseItemAsync(productId, {
accountIdentifiers: {
obfuscatedAccountId: null,
obfuscatedProfileId: null,
} as any,
});
Has anybody experienced a similar issue with finishTransactionAsync
? We're getting reports of issues on Android, receiving the following error:
Error: Encountered an exception while calling native method: Exception occurred while executing exported method finishTransactionAsync on module ExpoInAppPurchases: Attempt to invoke virtual method 'void expo.modules.inapppurchases.BillingManager.acknowledgePurchaseAsync(java.lang.String, expo.modules.core.Promise)' on a null object reference
[email protected] was published on 2022-10-25 and includes https://github.com/expo/expo/pull/18272, which should resolve this issue.