appsflyer-react-native-plugin icon indicating copy to clipboard operation
appsflyer-react-native-plugin copied to clipboard

TypeError: null is not an object (evaluating 'RNAppsFlyer.initSdkWithPromise') with Expo on Android Emulator

Open JeremyColton opened this issue 3 years ago • 12 comments

I am trying to init the AppsFlyer in my Expo 46 project on my Android emulator (Pixel_4 phone running Android API 28).

Here's my package.json:

	"dependencies": {
		"@react-native-async-storage/async-storage": "~1.17.3",
		"expo": "46.0.0",
		"expo-constants": "~13.2.4",
		"expo-font": "~10.2.0",
		"expo-location": "~14.3.0",
		"expo-notifications": "~0.16.1",
		"expo-splash-screen": "~0.16.2",
		"expo-status-bar": "~1.4.0",
		"expo-tracking-transparency": "^2.3.1",
		"expo-updates": "~0.14.5",
		"react": "18.0.0",
		"react-dom": "18.0.0",
		"react-native": "0.69.5",
		"react-native-appsflyer": "6.8.2",
		"react-native-safe-area-context": "4.3.1",
		"react-native-web": "~0.18.7",
		"react-native-webview": "11.23.0"
	}

My apps.json:

"plugins": [
			[
				"react-native-appsflyer",{}
			]
		]

Here's the code that is run:

import appsFlyer from 'react-native-appsflyer'

export const init = async () => {
	try {
		console.log(`0 init AppsFlyer with devKey: YYYY`)
		appsFlyer.initSdk({
				"isDebug": true,
				"devKey": "XXXX",
				"onInstallConversionDataListener": true,
				"onDeepLinkListener": true,
				"timeToWaitForATTUserAuthorization": 10,
				"appId": "YYYY"
			}, (result) => {
				console.log(`in success handler of appsflyer sdk init...`)
				console.log(result)
			},
			(error) => {
				console.log(`in error handler of appsflyer sdk...`)
				console.error(error)
			})
		console.log(`1. init AppsFlyer ok`)
	} catch (error) {
		console.log(error)
	}
}

In the WebStorm terminal I run:

npm i
npm start

My emulator opens and the splash screen shows and hangs.

In my Webstorm terminal I see:

Logs for your project will appear below. Press Ctrl+C to exit.
› Opening on Android...
› Opening exp://192.168.1.12:19000 on Pixel_4_API_28
› Press ? │ show all commands
Android Bundling complete 8277ms
LOG  0 c). init AppsFlyer with devKey: YYYY
 LOG  [TypeError: null is not an object (evaluating 'RNAppsFlyer.initSdkWithPromise')]

I googled this error message RNAppsFlyer.initSdkWithPromise but found nothing and after hours of different attempts I am stuck.

I also ran this on my iphone 8 running iOS15.6.1by scanning the QR code provided by the npm start command and see the same error message.

Do I need to separately install the AppsFlyer SDK or does this come with your API?

Can you please help?

JeremyColton avatar Oct 09 '22 15:10 JeremyColton

I am having the same issue, any updates?

nicusbonannus avatar Oct 11 '22 19:10 nicusbonannus

same issue

cankilinc avatar Oct 16 '22 11:10 cankilinc

any updates ? @JeremyColton @nicusbonannus

cankilinc avatar Oct 16 '22 12:10 cankilinc

@JeremyColton this api is part of the sdk. Do you work with expo-dev-client as mentioned here?

amit-kremer93 avatar Oct 20 '22 08:10 amit-kremer93

@amit-kremer93 yes but same error

cankilinc avatar Oct 20 '22 13:10 cankilinc

👋 Hi @JeremyColton and Thank you for reaching out to us. In order for us to provide optimal support, please submit a ticket to our support team at [email protected]. When submitting the ticket, please specify:

  • ✅ your AppsFlyer sign-up (account) email
  • ✅ app ID
  • ✅ production steps
  • ✅ logs
  • ✅ code snippets
  • ✅ and any additional relevant information.

github-actions[bot] avatar Nov 02 '22 07:11 github-actions[bot]

Having the same issue as well

Did anyone find a fix?

Ali-Olliek avatar Nov 15 '22 17:11 Ali-Olliek

I'm having the same issue...

ApollonNishikawa avatar Nov 19 '22 07:11 ApollonNishikawa

any updates?

artklen avatar Mar 30 '23 11:03 artklen

In my case you can resolve this issue by following these steps

Either clear your simulator and reinstall the app or:

> $ cd android > $ ./gradlew uA > $ ./gradlew clean or > $ npx react-native clean Now follow manual linking steps for Android Open Android Studio and sync gradle files then install & start android

louisraetz avatar Sep 14 '23 13:09 louisraetz

We had this issue as well, I believe we resolved it by following the manual install steps for android.

CTOverton avatar Nov 27 '23 19:11 CTOverton

This how I was able to resolve this in Expo SDK 49 using a dev-client

I created a new dev-client build after installing react-native-appsflyer and things started working

The reason for this is because react-native-appsflyer is on the native layer and not the JS layer so you need to create a new build that bundles the react-native-appsflyer native code.

aremu-smog avatar Apr 04 '24 09:04 aremu-smog