6

I am trying to set up a new Project with Skobbler. I've integrated the SKMaps.jar and put it into the buildpath. I am using AndroidStudio with gradl.

Now the problem is: The moment when I call

SKMaps.getInstance().initializeSKMaps(this, initMapSettings, getString(R.string.skobbler_api_key));

it throws an exception

android.view.InflateException: Binary XML file line #44: Error inflating class com.skobbler.ngx.map.SKMapViewHolder

and

Couldn't load ngnative from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/de.aeins.theswap.swap-1.apk"],nativeLibraryDirectories=[/data/app-lib/de.aeins.theswap.swap-1, /vendor/lib, /system/lib]]]: findLibrary returned null

I've got the lib folder in my project root and inside the SKMaps.jar and the 3 libngnative.so files in the seperate folders.

Any idea what's going wrong?

Francois Bourgeois
  • 3,650
  • 5
  • 30
  • 41
Fabio Schmitz
  • 135
  • 1
  • 7
  • Do you get this in the simulator or on the device? If it's on the device, what device are you using? – Ando Jun 03 '14 at 09:44
  • It's on the device (Nexus 5 with Android 4.4.2 – Fabio Schmitz Jun 03 '14 at 10:20
  • Do you have any issues with running the Android demo project on the same device? – Ando Jun 03 '14 at 13:47
  • No, this works. I have checked it many times against my project. I do not find the fault. – Fabio Schmitz Jun 03 '14 at 13:52
  • In addition it says in the Preview Window in AndroidStudio (I've added a SKMapViewHolder in an Activity): java.lang.UnsatisfiedLinkError: no ngnative in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886) at java.lang.Runtime.loadLibrary0(Runtime.java:849) at java.lang.System.loadLibrary(System.java:1088) at com.skobbler.ngx.map.MapRenderer.(SourceFile:47) at com.skobbler.ngx.map.SKMapSurfaceView.a(SourceFile:333) at com.skobbler.ngx.map.SKMapSurfaceView.(SourceFile:245) .... – Fabio Schmitz Jun 03 '14 at 13:53
  • Ok - we're looking into this (realistically expect an answer by this time tomorrow) – Ando Jun 03 '14 at 13:59

4 Answers4

2

I was just having the same issue.

A couple of thoughts (this is how I got it to work)

1) make sure you add the SKMaps.jar file in properties->Java Build Path->Libraries, and that it is selected in Order and Export

2) I realized in the demo app that a bunch of work was being done in the SplashActivity - specifically initializing the library. I assume that this must be done before the layout is inflated in an Activity. I ended up putting a SplashActivity in my app, initializing the library there before going to the Activity that displays the map, and it now works.

  • Hey. Thanks for this! 1) I am using AndroidStudio, so it has to be in the Projects Dependencies or am I missing the "Java Build Path" section here? 2) I've tried that already. My MapActivity is not the first, so I tried to initialize the Library in the first Activity. This has the result that the app did not even start but crashes directly. – Fabio Schmitz Jun 04 '14 at 05:37
  • I've tried it again, seperated the initialization in another activity, but allways got the error "java.lang.UnsatisfiedLinkError: Couldn't load ngnative from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/de.aeins.theswap.swap-1.apk"],nativeLibraryDirectories=[/data/app-lib/de.aeins.theswap.swap-1, /system/lib]]]: findLibrary returned null" – Fabio Schmitz Jun 04 '14 at 06:20
  • Ahh yes - I'm using Eclipse. But it sounds like you're having a problem with the either the SKMaps.jar file or the Native library - libngnative.so. I'm not familiar with Android Studio, but you could maybe search on adding exeternal jars and/or native libraries in Android Studio. – Britton Peddie Jun 04 '14 at 17:06
1

I had the same problem. Fixed it by:

  1. Putting lib/armeabi/libngnative.so, lib/armeabi-v7a/libngnative.so and lib/x86/libngnative.so in a zip file.
  2. Rename zipfile to libngnative.jar
  3. Move jarfile to app/libs
  4. Add jarfile as file dependency
Erik
  • 83
  • 9
  • Thanks a lot! This fixed the part of not getting the .so files in place. But still the ActivityInflator says "java.lang.RuntimeException: Unable to start activity ComponentInfo{de.aeins.theswap.swap/de.aeins.theswap.swap.map}: android.view.InflateException: Binary XML file line #52: Error inflating class com.skobbler.ngx.map.SKMapViewHolder". Also the PreviewWindow of my Activity shows the error "The following classes could not be instantiated: - com.skobbler.ngx.map.SKMapViewHolder (Open Class, Show Exception)" – Fabio Schmitz Jun 05 '14 at 12:00
1

In Android Studio projects the native .so libraries should be placed in the /app/src/main/ folder in order to be recognised: enter image description here

This may be the cause of your crash. Some similar problems were reported on stackoverflow.com:

JNI folder in Android Studio

Adding a .so file in Android Studio

Community
  • 1
  • 1
Ando
  • 11,199
  • 2
  • 30
  • 46
1

It is import to put the map initialization part into its own activity, which is launched initially, as in the SplashActivity of the Skobbler AndroidOpenSourceDemo application. I.e. the initialization has to be done in its own startup activity and from there, a new (main) activity is started, that is showing the map (SKMapViewHolder xml element).

(Also, when in doubt, uninstall the application manually on the device, before running it again.)

Alexander Roehnisch
  • 675
  • 1
  • 7
  • 10