AppsFlyerSDK / appsflyer-react-native-plugin

AppsFlyer plugin for React Native
MIT License
285 stars 202 forks source link

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

Open JeremyColton opened 2 years ago

JeremyColton commented 2 years ago

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?

nicusbonannus commented 2 years ago

I am having the same issue, any updates?

cankilinc commented 2 years ago

same issue

cankilinc commented 2 years ago

any updates ? @JeremyColton @nicusbonannus

amit-kremer93 commented 2 years ago

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

cankilinc commented 2 years ago

@amit-kremer93 yes but same error

github-actions[bot] commented 2 years ago

👋 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 support@appsflyer.com. When submitting the ticket, please specify:

Ali-Olliek commented 2 years ago

Having the same issue as well

Did anyone find a fix?

ApollonNishikawa commented 1 year ago

I'm having the same issue...

artklen commented 1 year ago

any updates?

louisraetz commented 1 year ago

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

CTOverton commented 11 months ago

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

aremu-smog commented 7 months ago

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.

xx-git commented 1 day ago

I also encountered the same problem, how to solve it?