Adding an Skobbler Map to my empty App
Asked Answered
R

4

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?

Rodriquez answered 3/6, 2014 at 7:50 Comment(6)
Do you get this in the simulator or on the device? If it's on the device, what device are you using?Dugas
It's on the device (Nexus 5 with Android 4.4.2Rodriquez
Do you have any issues with running the Android demo project on the same device?Dugas
No, this works. I have checked it many times against my project. I do not find the fault.Rodriquez
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.<clinit>(SourceFile:47) at com.skobbler.ngx.map.SKMapSurfaceView.a(SourceFile:333) at com.skobbler.ngx.map.SKMapSurfaceView.<init>(SourceFile:245) ....Rodriquez
Ok - we're looking into this (realistically expect an answer by this time tomorrow)Dugas
F
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.

Faxen answered 4/6, 2014 at 1:37 Comment(3)
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.Rodriquez
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"Rodriquez
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.Faxen
K
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
Knecht answered 5/6, 2014 at 10:42 Comment(1)
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)"Rodriquez
D
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

Dugas answered 17/6, 2014 at 9:31 Comment(0)
N
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.)

Nottage answered 14/7, 2014 at 13:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.