-1

We use firebase crashlytics to monitor crashes in production and since updating to 3.18 we are getting this error in production(release), this never happens in development. I think the error is in Here's source code because I have a null-check before the init method.

Fatal Exception: java.lang.NullPointerException: Context is null
       at java.util.Objects.requireNonNull(Objects.java:228)
       at com.nokia.maps.f4.a(Preconditions.java:1)
       at com.nokia.maps.v.<init>(AppContextImpl.java:13)
       at com.here.android.mpa.common.ApplicationContext.<init>(ApplicationContext.java:2)
       at com.here.android.mpa.mapping.AndroidXMapFragment.init(AndroidXMapFragment.java:1)
       at my.package.app.fragments.navegacionhere.MapFragmentView.initMapFragment(MapFragmentView.java:538)
       at my.package.app.fragments.navegacionhere.MapFragmentView.<init>(MapFragmentView.java:160)
       at my.package.app.activity.llamadas.DetalleLlamadaActivity.setupMapFragmentView(DetalleLlamadaActivity.java:1339)
dariovaz
  • 31
  • 4
  • I have a null-check before I call the init() method, this feature has been working for months and I NEVER got the exception in development, or in prod before updating HERE SDK to 3.18 – dariovaz Sep 01 '21 at 14:05
  • Could you please confirm the exact Here SDK version to help us de-symobolicate the log? The complete version would be something 3.18.x. –  Sep 06 '21 at 12:50
  • The version I am using in my project is 3.18.4 – dariovaz Sep 07 '21 at 06:58

1 Answers1

0

Generally, this exception occurs in AndroidXMapFragment.init(...) when activity has not been attached to the fragment. You can use the below method instead if fragment.getActivity() is null, and provide any Android Context for the ApplicatoinContext constructor, it should not be the context of an Activity. https://developer.here.com/documentation/android-premium/3.18/api_reference_java/com/here/android/mpa/mapping/AndroidXMapFragment.html#init-com.here.android.mpa.common.ApplicationContext-com.here.android.mpa.common.OnEngineInitListener-

public void init(@NonNull
ApplicationContext context,
@NonNull
OnEngineInitListener listener)
Initializes the MapEngine and displays a map that occupies the entire AndroidXMapFragment's view rectangle. Users of AndroidXMapFragment should call this method after the fragment is first attached to its activity.
This method can be used for AndroidXMapFragment objects that are created programmatically or declared in a layout XML file.

This method will initialize MapEngine with ApplicationContext to be used during initialization.

Parameters:
context - ApplicationContext to be used during initialization.
listener - A OnEngineInitListener object that will be called when AndroidXMapFragment initialization is finished. A null object can be supplied if the caller does not require any notification when initialization completes.
See Also:
OnEngineInitListener, MapEngine.init(ApplicationContext, OnEngineInitListener)

ApplicationContext

public ApplicationContext(@NonNull
android.content.Context ctx)
Creates a ApplicationContext with specified application context.
Parameters:
ctx - Application context.

Link to the above code: https://developer.here.com/documentation/android-premium/3.18/api_reference_java/com/here/android/mpa/common/ApplicationContext.html#ApplicationContext-android.content.Context-

For further investigation, we need the code snippet for null check.