layout problem, could not be instantiated MapView

161 views
Skip to first unread message

Tiago Brito

unread,
Nov 28, 2014, 1:21:54 PM11/28/14
to nutit...@googlegroups.com
Hi.

I'm trying to use Nutiteq SDK 3.0 but I have a problem.
I'm using Android Studio 0.8.14

in my layout I have:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <com.nutiteq.ui.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
</RelativeLayout>

and it gives me this error:
The following classes could not be instantiated:
- com.nutiteq.ui.MapView


expection details:

java.lang.UnsatisfiedLinkError: no nutiteq_maps_sdk in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at com.nutiteq.ui.MapView.<clinit>(MapView.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:379)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:99)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:206)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:131)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:756)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:728)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:373)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:393)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:337)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:674)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:663)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:663)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:790)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)


any help with this?

Jaak Laineste (Nutiteq)

unread,
Nov 28, 2014, 1:25:23 PM11/28/14
to nutit...@googlegroups.com
Hello,

The error means that native part of the library is not compiled into the project.

I have Android Studio 0.8.9 for Mac and imported hellomap and advancedmap3 example projects to it (using import Eclipse project). The result seems to work fine, you can check the structure and versions of the plugins, NDK .so library must be in correct folder. I put my imported working project temporarily here: dl.dropboxusercontent.com/u/3573333/com.nutiteq.hellomap3.zip , maybe it helps

You should check Android studio and plugin and Gradle versions, any of them could be relevant. Also what is your device - you need x86 library for Genymotion for example, and armeabi for most physical devices (it works fine also on x86 Atom devices, but not on Genymotion emulator).

Jaak



--
You received this message because you are subscribed to the Google Groups "Nutiteq-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nutiteq-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tiago....@gmail.com

unread,
Dec 1, 2014, 2:21:17 PM12/1/14
to nutit...@googlegroups.com
Ok. I tried on a MAC with this settings(whit your project):
Android Studio version 0.8.9
Gradle Version 1.12
Gradle Plugin Version 0.12.2

AVD:
Device: Galaxy Nexus (4.65", 720x1280:xhdpi)
Target: Android 4.4.2 - API Level 19
CPU: ARM (armbi-v7a)
RAM: 512

and no luck.

Maybe it has something to do with the name of the file "libnutiteq_maps_sdk.so" ?

because it says "java.lang.UnsatisfiedLinkError: no nutiteq_maps_sdk in java.library.path"

thanks

Jaak Laineste (Nutiteq)

unread,
Dec 1, 2014, 3:53:07 PM12/1/14
to nutit...@googlegroups.com
On 01 Dec 2014, at 19:21, tiago....@gmail.com wrote:

Sexta-feira, 28 de Novembro de 2014 18:25:23 UTC, Jaak Laineste escreveu:
Hello,


The error means that native part of the library is not compiled into the project.


Ok. I tried on a MAC with this settings(whit your project):
Android Studio version 0.8.9
Gradle Version 1.12
Gradle Plugin Version 0.12.2

AVD:
Device: Galaxy Nexus (4.65", 720x1280:xhdpi)
Target: Android 4.4.2 - API Level 19
CPU: ARM (armbi-v7a)
RAM: 512

and no luck.

Maybe it has something to do with the name of the file "libnutiteq_maps_sdk.so" ?

because it says "java.lang.UnsatisfiedLinkError: no nutiteq_maps_sdk in java.library.path”


No, I don’t think so. The library file name should always have lib in beginning and .so in the end, even through it is shown as shorter in the code. And this configuration works fine for me. Maybe Android SDK or NDK version or existence makes any sense.

Jaak


Ale Perez

unread,
Dec 2, 2014, 6:04:55 AM12/2/14
to nutit...@googlegroups.com, tiago....@gmail.com
Hi Tiago,
one week ago I had the same problem with some .so's, 

My trouble was, that I began my project with a version of "advancedMaps3d" Example and actualized it often so that I got this Exception "UnsatisfiedLinkException" and then, with the proper .so's I could eliminate this exception but the calls to native methods didn't coincide any longer because an upgrade of nutiteq_-3d-sdkxxx.jar and other .jar's.

So, try to go back to your original "advancedMap" (I hope, you have based your project to "advancedMap3d" and not to "advancedLayers" because advancedLayers-1.0-SNAPSHOT.jar could collide with the packages of "advancedLayers" Example) and take a look at all of jar's and .so and if there have a difference with your actual, then you can properly change.


Cumprimento

tiago....@gmail.com

unread,
Dec 5, 2014, 5:17:00 AM12/5/14
to nutit...@googlegroups.com, tiago....@gmail.com
Ok lets see if I understand.

I have to start my project with "advancedmap3" ? from here?
https://github.com/nutiteq/hellomap3d-android

Jaak Laineste (Nutiteq)

unread,
Dec 5, 2014, 5:31:25 AM12/5/14
to nutit...@googlegroups.com, tiago....@gmail.com
Hello,

For first minimal getting started even simpler would be hellomap3 from the https://github.com/nutiteq/hellomap3d-android project, but for real production app it is probably too simplistic. For example it forgets map state when you rotate device (change orientation), advancedmap3 has code for that also.

Jaak

tiago....@gmail.com

unread,
Dec 5, 2014, 5:48:25 AM12/5/14
to nutit...@googlegroups.com, tiago....@gmail.com
Ok. So what I need is really the "advancedmap3" since it is for real production app.

I tried to open the project (https://github.com/nutiteq/hellomap3d-android/tree/master/com.nutiteq.advancedmap3) in eclipse to see if it works and it gives me the same error.

Ale Perez

unread,
Dec 5, 2014, 6:43:43 AM12/5/14
to nutit...@googlegroups.com, tiago....@gmail.com
Hi Tiago,

here you can download as the jar's as the armeabi/xxx.so files which work for me but I work under the SDK 2.3.1, so, if you have a later version of "AdvancedMap3D", then you should adapt your code in order that you can begin to play with the app. I.e. WmsLayer is deprecated and replaced in SDK 2.4.0 and therefore, in AdvancedMAp3D for that version you won't be able to see and so on with other Classes.



Here the Picture which proofs that works http://www.mediafire.com/view/p017xsx5bq4s6fp/Screenshot_2014-12-05-12-38-01.png

Kind Regards.

Ale Perez

unread,
Dec 5, 2014, 7:06:40 AM12/5/14
to nutit...@googlegroups.com, tiago....@gmail.com
I have "AvancedMaps3D" Source which works with this libraries, If Jaak allows, I can send a link with the packed file and then you could make what you want. The you should be capable to adapt your code to this "AdvancedMap3D".

Kind Regards


On Friday, December 5, 2014 11:48:25 AM UTC+1, tiago....@gmail.com wrote:

Jaak Laineste (Nutiteq)

unread,
Dec 5, 2014, 7:21:42 AM12/5/14
to nutit...@googlegroups.com, tiago....@gmail.com

AdvancedMap3D is by default name for SDK 2.4 sample project. Nutiteq SDK 3.0 has project com.nutiteq.advancedmap3 (without “D”). I know, it is quite similar in name and can be confusing. Are you sure you refer to the same thing?

Sure, you can share your sample app projects, our sample app code is free and open.

Jaak

Ale Perez

unread,
Dec 5, 2014, 9:49:11 AM12/5/14
to nutit...@googlegroups.com, tiago....@gmail.com
You are right, I overlooked, he wanted to do it with SDK 3.0 but I suspect like you, he mixed projects (as I 1 week ago) and now he cannot use the example.

tiago....@gmail.com

unread,
Dec 5, 2014, 1:35:30 PM12/5/14
to nutit...@googlegroups.com, tiago....@gmail.com
Hum.. but even if I download de sample project of sdk 3.0 I cannot use it.

That's the major problem :/

Jaak Laineste (Nutiteq)

unread,
Dec 5, 2014, 2:22:44 PM12/5/14
to nutit...@googlegroups.com, tiago....@gmail.com
Hello,

Well, there can be several things wrong, but it works for us. Can you share for example screencast video and share what you did, from fresh clone of hellomap3d-android project, to your problem?

Jaak

tiago....@gmail.com

unread,
Dec 6, 2014, 5:57:56 AM12/6/14
to nutit...@googlegroups.com, tiago....@gmail.com
Here it is:

In Eclipse Luna(with adt plugin): https://copy.com/Wj8EyzIXMuyzHc4z
In Android Studio 1.0 RC4: https://copy.com/sDtGoHaJNoKc3uic

Jaak Laineste (Nutiteq)

unread,
Dec 8, 2014, 8:05:17 AM12/8/14
to nutit...@googlegroups.com, tiago....@gmail.com
Hello,

Thanks for the videos. I wish everyone would bother to post something like that.

General suggestions:
 1. Use git download instead of download whole project. This way you would get easily cumulative updates of the project, and if you fix something then you can even create Pull Request to be applied.
 2. if you have problem with Emulator, try real device.

It looks you have different issues on different IDEs even though they may look similar:

About Eclipse:

The project looks fine - you have JAR file in /libs and /libs/armeabi with .so file. 

 1. I would just import Project, not as Android project. I don’t know if there is major difference in this.

 2. Error message tells “show error log”, can you check what is given there.

 3. Eclipse keeps project internal links broken sometimes. This kind of errors have been quite fixed with seemingly random and stupid sequence of project clean-refresh-builds. You may seen non-sense error messages which are fixed by these also non-sense keypresses. Don’t ask why. 

About Android Studio:
 1. See comments for similar question here: http://stackoverflow.com/questions/27188750/nutiteq-in-android-studio-0-8-14 . I don’t see from the video that gradle version things were all properly fixed. If not, you get similar issue as with Eclipse, even the internal reason is different; with Android Studio you can fix the dependencies in configuration more nicely, not with random clicks. It does not mean that it is much less painful: many AS updates requires new specific gradle versions etc. Result should be same: project without visible errors.

 2. You try to use Genymotion emulator.This is x86 device, but the advancedmap3d project has armeabi binary library. You must use x86 build of Nutiteq SDK for Genymotion. Note that on real physical x86 devices you do not have this problem, as they can emulate ARM (armeabi) binary quite well. The problem is only with the emulator. Using x86 build on real x86 device could give say 20% performance improvement, depending what your app does exactly. So you may want to try it out. See below how to get and use x86 build.

 3. Always also with physical device or Android own emulator with arm cpu - do you get same issue? You should not.

Using x86 (and other archs) of Nutiteq SDK:

This is relevant for Genymotion mostly. You may have also x86 device not supporting ARM emulation (I don’t know any, but there are so many devices that some may miss Intel emulation level), or one of very few MIPS devices. There are several ways to do this:

a) With Maven pom.xml file. You can do it in command-line or Eclipse Maven tools. Theory is simple, add following dependencies for SDK 3.0 RC: https://gist.github.com/jaakla/312775a7632e2bf1d438 as pom.xml file. You must have two Nutiteq deps: nutiteq-sdk (Java part, jar file) and libnutiteq_maps_sdk (Native part, so file). The second one has additional parameter classifier which needs to be armeabi in most real devices, but specifically for Geanymotion you need to define the value as x86 . This should do it - you have build which runs on Genymotion. In practise getting maven to run properly in Eclipse and Android may be painful, it requires to install right versions of right additional plugins. m2e Android Connector is the main one, but this may need others. With command-line only recent maven should be enough, so in project folder you enter command which should do all magic and install app to device:
mvn install android:deploy android:run

b) Manual hack, if you are not that patient with Maven. You can also download specific .so file from Maven repo directly, using URL: https://repository-nutiteq.forge.cloudbees.com/release/com/nutiteq/libnutiteq_maps_sdk/ . You should get a so file based on required architecture, e.g. libnutiteq_maps_sdk-3.0.0RC0-x86.so for x86. Now create folder x86 in the same place where armeabi is (in libs in Eclipse, or src/main/jniLibs in Android Studio). Finally rename file to libnutiteq_maps_sdk.so . 

See attached screenshot from Android studio working project: 



Final warning: having all architectures like armeabi and x86 in same project means that the APK file is several megabytes larger, as you have several copies of the native binary part. In this sense it would be better to have two separate builds and APKs, or use only armeabi to publish app to Play Store. This means some careful building or proper build scripts.


Jaak

tiago....@gmail.com

unread,
Dec 8, 2014, 9:27:56 AM12/8/14
to nutit...@googlegroups.com, tiago....@gmail.com
Thanks a lot for your help.

Finally I managed to get "advancedmap3" working in Android Studio.

Here is all the info os System and versions that I'm using:

Windows 8.1 Pro x64
Android Studio 1.0 RC4
Graddle 2.2.1

AVD for running:
Device: "Nexus 4 (4.7", 768x1280:xhdpi)"
Target: Android 4.4.2 - API Level 19
CPU/ABI: ARM (armeabi-v7a)

Instructions
Git clone of the project
Import Non-Android Studio project
In build.gradle (Module: com.nutiteq.advancedmap3) change:

dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}

to

dependencies {
classpath 'com.android.tools.build:gradle:0.14.+'
}

and

release {
runProGuard false
proguardFile 'proguard-project.txt'
}

to

release {
minifyEnabled false
proguardFile 'proguard-project.txt'
}

then sync project.

If we open res/layout/activity_main.xml will show the error of the class cannot be instanciated anyway, but the project will run without problem.

I will now try and use it in my current project.

Thanks for the help :)

Segunda-feira, 8 de Dezembro de 2014 13:05:17 UTC, Jaak Laineste escreveu:
> Hello,
>
>
> Thanks for the videos. I wish everyone would bother to post something like that.
>
>
> General suggestions:
>  1. Use git download instead of download whole project. This way you would get easily cumulative updates of the project, and if you fix something then you can even create Pull Request to be applied.
>  2. if you have problem with Emulator, try real device.
>
>
> It looks you have different issues on different IDEs even though they may look similar:
>
>
> About Eclipse:
>
>
> The project looks fine - you have JAR file in /libs and /libs/armeabi with .so file. 
>
>
>  1. I would just import Project, not as Android project. I don’t know if there is major difference in this.
>
>
>  2. Error message tells “show error log”, can you check what is given there.
>
>
>  3. Eclipse keeps project internal links broken sometimes. This kind of errors have been quite fixed with seemingly random and stupid sequence of project clean-refresh-builds. You may seen non-sense error messages which are fixed by these also non-sense keypresses. Don’t ask why. 
>
>
> About Android Studio:
>  1. See comments for similar question here: http://stackoverflow.com/questions/27188750/nutiteq-in-android-studio-0-8-14 . I don’t see from the video that gradle version things were all properly fixed. If not, you get similar issue as with Eclipse, even the internal reason is different; with Android Studio you can fix the dependencies in configuration more nicely, not with random clicks. It does not mean that it is much less painful: many AS updates requires new specific gradle versions etc. Result should be same: project without visible errors.
>
>
>  2. You try to use Genymotion emulator.This is x86 device, but the advancedmap3d project has armeabi binary library. You must use x86 build of Nutiteq SDK for Genymotion. Note that on real physical x86 devices you do not have this problem, as they can emulate ARM (armeabi) binary quite well. The problem is only with the emulator. Using x86 build on real x86 device could give say 20% performance improvement, depending what your app does exactly. So you may want to try it out. See below how to get and use x86 build.
>
>
>  3. Always also with physical device or Android own emulator with arm cpu - do you get same issue? You should not.
>
>
> Using x86 (and other archs) of Nutiteq SDK:
>
>
> This is relevant for Genymotion mostly. You may have also x86 device not supporting ARM emulation (I don’t know any, but there are so many devices that some may miss Intel emulation level), or one of very few MIPS devices. There are several ways to do this:
>
>
> a) With Maven pom.xml file. You can do it in command-line or Eclipse Maven tools. Theory is simple, add following dependencies for SDK 3.0 RC: https://gist.github.com/jaakla/312775a7632e2bf1d438 as pom.xml file. You must have two Nutiteq deps: nutiteq-sdk (Java part, jar file) and libnutiteq_maps_sdk (Native part, so file). The second one has additional parameter classifier which needs to be armeabi in most real devices, but specifically for Geanymotion you need to define the value as x86 . This should do it - you have build which runs on Genymotion. In practise getting maven to run properly in Eclipse and Android may be painful, it requires to install right versions of right additional plugins. m2e Android Connector is the main one, but this may need others. With command-line only recent maven should be enough, so in project folder you enter command which should do all magic and install app to device:
> mvn install android:deploy android:run
>
>
> b) Manual hack, if you are not that patient with Maven. You can also download specific .so file from Maven repo directly, using URL: https://repository-nutiteq.forge.cloudbees.com/release/com/nutiteq/libnutiteq_maps_sdk/ . You should get a so file based on required architecture, e.g. libnutiteq_maps_sdk-3.0.0RC0-x86.so for x86. Now create folder x86 in the same place where armeabi is (in libs in Eclipse, or src/main/jniLibs in Android Studio). Finally rename file to libnutiteq_maps_sdk.so . 
>
>
> See attached screenshot from Android studio working project: 
>
>
>
>
>
>
>

Jaak Laineste

unread,
Dec 11, 2014, 8:05:05 AM12/11/14
to nutit...@googlegroups.com, tiago....@gmail.com
Hi,

 
If we open res/layout/activity_main.xml will show the error of the class cannot be instanciated anyway, but the project will run without problem.

I will now try and use it in my current project.

Thanks for the help :)

Right, Android Studio cannot load SDK native library part in IDE , so it cannot render map in visual designer. But you can safely ignore this issue: only bad result is that you see gray box instead of map in the visual design mode. Hopefully next Android Studio versions will be smarter about this, and maybe one day we will even enable changing visual design of the map in the Android Studio. It is a bit related to very limited native Android (NDK) support in current Android Studio.

Jaak
Reply all
Reply to author
Forward
0 new messages