prscX / react-native-app-tour

React Native: Native App Tour Library
Apache License 2.0
640 stars 119 forks source link

Getting error : java.lang.NullPointerException #88

Open Boubaker93 opened 4 years ago

Boubaker93 commented 4 years ago

Hello, In my last version of my app i upgraded react-native-app-tour from version 0.0.19 to version 1.0.2 and i started getting this error in my deployed version java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme().

Here is the a full stacktrace of the error :

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference
       at android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:227)
       at android.app.AlertDialog$Builder.<init>(AlertDialog.java:461)
       at ui.apptour.RNAppTourModule.ShowSequence(RNAppTourModule.java:70)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:371)
       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:150)
       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:808)
       at android.os.Handler.dispatchMessage(Handler.java:101)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:26)
       at android.os.Looper.loop(Looper.java:166)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:225)
       at java.lang.Thread.run(Thread.java:784) 

Here is an exemple how i'm using the lib in my code :

<TouchableOpacity
         disabled
         key='example'
         ref={ref => {
             if (!ref) return
             const props = tutorialProps. example
             if (addAppTourTarget) {
                 addAppTourTarget(AppTourView.for(ref, { ...props }))
             }
         }}>
         <MyComponent />
</TouchableOpacity>

Then in my app.js i use this once my appTourTargets have the length i want it :

    if (appTourTargets.length === length) {
        const appTourSequence = new AppTourSequence()
        appTourTargets.forEach(appTourTarget => {
            appTourSequence.add(appTourTarget)
        })
        AppTour.ShowSequence(appTourSequence)
    }

I'm using using react-native: 0.61.5

Thanks for your help

prscX commented 4 years ago

Thanks @Boubaker93 for raising the issue.

Considering you are using latest RN, could you try it with latest version of the library 1.*

Let me know incase it does not work.

Thanks </ Pranav >

Eesssn commented 4 years ago

same issue. i use RN 0.61.5 and app-tour version 1.0.2 but got same error

@Boubaker93 i have a solution (but not good solution, just for running away from this issue :) ) run this command " gradlew assembleRelease -x lintVitalRelease " it works. this library should debug. thank @prscX

Boubaker93 commented 4 years ago

Yes me too i'm getting this error in version 1.0.2.

@Eesssn will try that out but as you said the best solution :D

thx for that @Eesssn

SaidDos commented 3 years ago

same crash here i'm using react-native-app-tour version 1.0.4

gr0x0 commented 1 year ago

Hello. This issue is still happening. Any updates?

My specs: RN 0.67.5 app-tour version 1.0.5