geoadmin / lib-open-swiss-maps-sdk

Android and iOS SDK to display maps and geodata of swisstopo. Owner: simonroesch, Deputy: gjn
https://www.swisstopo.ch/sdk
Mozilla Public License 2.0
37 stars 4 forks source link

missing coordinate system #118

Closed ceoy closed 1 year ago

ceoy commented 1 year ago

We have an android app that has a SwisstopoMapView.

now in production, we receive quite a few errors via sentry, but we cannot reproduce the issue on any of our devices.

java.lang.UnsatisfiedLinkError: No implementation found for io.openmobilemaps.mapscore.shared.map.coordinates.MapCoordinateSystem io.openmobilemaps.mapscore.shared.map.coordinates.CoordinateSystemFactory$CppProxy.getEpsg2056System() (tried Java_io_openmobilemaps_mapscore_shared_map_coordinates_CoordinateSystemFactory_00024CppProxy_getEpsg2056System and Java_io_openmobilemaps_mapscore_shared_map_coordinates_CoordinateSystemFactory_00024CppProxy_getEpsg2056System__)
    at io.openmobilemaps.mapscore.shared.map.coordinates.CoordinateSystemFactory$CppProxy.getEpsg2056System(SourceFile)
    at io.openmobilemaps.mapscore.shared.map.coordinates.CoordinateSystemFactory$CppProxy$Companion.getEpsg2056System
    at io.openmobilemaps.mapscore.shared.map.coordinates.CoordinateSystemFactory$Companion.getEpsg2056System
    at ch.admin.geo.openswissmaps.view.SwisstopoMapView.<init>(SourceFile:50)
    at ch.admin.geo.openswissmaps.view.SwisstopoMapView.<init>(SourceFile:37)
    at ch.admin.geo.openswissmaps.view.SwisstopoMapView.<init>(SourceFile:0)
    at java.lang.reflect.Constructor.newInstance0(Constructor.java)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
    at android.view.LayoutInflater.createView(LayoutInflater.java:876)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1028)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1145)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1106)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:544)
    at ch.mapapp.android.databinding.FragmentMapBinding.inflate
    at ch.mapapp.android.main.training.MapFragment.onCreateView(SourceFile:99)
    at androidx.fragment.app.Fragment.performCreateView(SourceFile:3104)
    at androidx.fragment.app.FragmentStateManager.ensureInflatedView(SourceFile:390)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(SourceFile:260)
    at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(SourceFile:142)
    at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:247)
    at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1083)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1019)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1145)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1106)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1148)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1106)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:544)
    at ch.mapapp.android.databinding.FragmentLocationsListWithMapBinding.inflate(SourceFile:84)
    at ch.mapapp.android.main.training.LocationsListWithMapFragment.onCreateView(SourceFile:40)
    at androidx.fragment.app.Fragment.performCreateView(SourceFile:3104)
    at androidx.fragment.app.FragmentStateManager.createView(SourceFile:526)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(SourceFile:261)
    at androidx.fragment.app.FragmentStore.moveToExpectedState
    at androidx.fragment.app.FragmentManager.moveToState(SourceFile:1424)
    at androidx.fragment.app.FragmentManager.moveToState(SourceFile:0)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(SourceFile:2968)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(SourceFile:0)
    at androidx.fragment.app.FragmentManager.dispatchViewCreated
    at androidx.fragment.app.Fragment.performViewCreated
    at androidx.fragment.app.FragmentStateManager.createView(SourceFile:552)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(SourceFile:261)
    at androidx.fragment.app.FragmentStore.moveToExpectedState
    at androidx.fragment.app.FragmentManager.moveToState(SourceFile:1424)
    at androidx.fragment.app.FragmentManager.moveToState(SourceFile:0)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(SourceFile:2968)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(SourceFile:0)
    at androidx.fragment.app.FragmentManager.dispatchActivityCreated
    at androidx.fragment.app.FragmentController.dispatchActivityCreated
    at androidx.fragment.app.FragmentActivity.onStart(SourceFile:351)
    at androidx.appcompat.app.AppCompatActivity.onStart(SourceFile:251)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1510)
    at android.app.Activity.performStart(Activity.java:8616)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:4204)
    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8757)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

java.lang.reflect.InvocationTargetException: null
    at java.lang.reflect.Constructor.newInstance0(Constructor.java)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
    at android.view.LayoutInflater.createView(LayoutInflater.java:876)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1028)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1145)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1106)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:544)
    at ch.mapapp.android.databinding.FragmentMapBinding.inflate
    at ch.mapapp.android.main.training.MapFragment.onCreateView(SourceFile:99)
    at androidx.fragment.app.Fragment.performCreateView(SourceFile:3104)
    at androidx.fragment.app.FragmentStateManager.ensureInflatedView(SourceFile:390)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(SourceFile:260)
    at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(SourceFile:142)
    at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:247)
    at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1083)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1019)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1145)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1106)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1148)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1106)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:544)
    at ch.mapapp.android.databinding.FragmentLocationsListWithMapBinding.inflate(SourceFile:84)
    at ch.mapapp.android.main.training.LocationsListWithMapFragment.onCreateView(SourceFile:40)
    at androidx.fragment.app.Fragment.performCreateView(SourceFile:3104)
    at androidx.fragment.app.FragmentStateManager.createView(SourceFile:526)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(SourceFile:261)
    at androidx.fragment.app.FragmentStore.moveToExpectedState
    at androidx.fragment.app.FragmentManager.moveToState(SourceFile:1424)
    at androidx.fragment.app.FragmentManager.moveToState(SourceFile:0)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(SourceFile:2968)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(SourceFile:0)
    at androidx.fragment.app.FragmentManager.dispatchViewCreated
    at androidx.fragment.app.Fragment.performViewCreated
    at androidx.fragment.app.FragmentStateManager.createView(SourceFile:552)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(SourceFile:261)
    at androidx.fragment.app.FragmentStore.moveToExpectedState
    at androidx.fragment.app.FragmentManager.moveToState(SourceFile:1424)
    at androidx.fragment.app.FragmentManager.moveToState(SourceFile:0)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(SourceFile:2968)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(SourceFile:0)
    at androidx.fragment.app.FragmentManager.dispatchActivityCreated
    at androidx.fragment.app.FragmentController.dispatchActivityCreated
    at androidx.fragment.app.FragmentActivity.onStart(SourceFile:351)
    at androidx.appcompat.app.AppCompatActivity.onStart(SourceFile:251)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1510)
    at android.app.Activity.performStart(Activity.java:8616)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:4204)
    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8757)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

proguard-rules.pro

-keep class io.openmobilemaps.mapscore.shared.** { *; }
-keep class openmobilemaps.mapscore.shared.** { *; }

version

...

minSdk 24
targetSdk 33

...

compileOptions {
    coreLibraryDesugaringEnabled true
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
    jvmTarget = "17"
}

bundle {
    language {
        enableSplit = false
    }
    density {
        enableSplit = true
    }
    abi {
        enableSplit = true
    }
}

...

implementation 'ch.admin.geo.openswissmaps:openswissmaps-sdk:1.5.1'

I'm not sure if there is something I am doing wrong or if this is an error you have seen before as well?

Thank you :)

maurhofer-ubique commented 1 year ago

Hey @ceoy,

It seems like it isn't able to find the native library of the maps-core module. Are you sure that you call OpenSwissMaps.initialize() early enough, e.g. in onCreate of your Application? This should take care of the necessary System.loadLibrary calls to properly load in the native libraries. I'm intrigued by the fact that you can't reproduce it on you own devices (debug and release builds?).

ceoy commented 1 year ago

I feel stupid 😆

Thanks to your input, I noticed that I've put OpenSwissMaps.initialize() inside the Activity's onCreate instead of the Application's onCreate.

When I kill the app and restart it, I can reproduce the issue and also confirm that moving the initialization to the application fixes the crash.

Thank you!