Closed feargswalsh92 closed 6 years ago
Yes, 2.x
versions of react-native-radar
is only compatible with 2.x
versions of the SDKs.
However you don't need to depend on the sdk manually as the react native module will include it transitively for you.
However this error seems to be from not initializing the sdk properly with:
Radar.initalize(context, publishable_key)
Ok thanks but I don't understand where context
is coming from.
All the docs say is that you need to initialize the sdk in MainApplication.java
with
Radar.initialize(publishableKey);
where publishableKey is a string containing your publishable API key
Also if I am setting up the places provider in my react native app, I don't need to also do it in onCreate()
correct?
Ah sorry about that, the API changed a bit between 1.x and 2.x. I think because you're including both versions of the SDK there is some confusion here.
react-native-radar will transitively pull in the correct Radar SDK dependency so you don't need to include it yourself in your build.gradle
. Since you're using react-native-radar version 1.x, you'll need to call the 1.x version in MainApplication.java
like so :
Radar.initalize(context, publishable_key)
To confirm you are using 1.x, the import should look like:
import com.onradar.sdk.Radar;
And you are correct, you don't need to set places provider in native code if you are doing it in react native app. Those settings will propagate correctly. Only initialization is required in native code (for now 😉 )
No worries. Nice yeah got me past that error, just using this
as the context. Oh I can figure out what that winky face means. We were also wondering is having the option to use a different places provider in the future scope? It seems like it based on the way it's passed in
We have no immediate plans to add another places provider, but we left the API open for the future in case we ever want to open up the options for consumers down the road.
Platform
Android
Radar version
Android : 2.0.4 React-Native: 1.0.17 Full error message:
Attempt to invoke virtual method 'android.content.SharedPreferences android.content.Context.getSharedPreferences(java.lang.String, int)' on a null object reference setPlacesProvider _RadarSettings.java:162 setPlacesProvider _Radar.java:110 setPlacesProvider Radar.java:132 setPlacesProvider RNRadarModule.java:47 invoke Method.java invoke JavaMethodWrapper.java:372 invoke JavaModuleWrapper.java:160 run NativeRunnable.java handleCallback Handler.java:739 dispatchMessage Handler.java:95 dispatchMessage MessageQueueThreadHandler.java:29 loop Looper.java:148 run MessageQueueThreadImpl.java:192 run Thread.java:818
I've been getting this error on Android for the last couple of days. As you know we had to downgrade the react-native-radar to make it work. Do we have to downgrade the Android sdk too?