2

I'd like to develop a companion application for my Tizen5.5 watch which uses information from the phone (Android host). I'm working on Windows 10 with Tizen Studio.

I found a nice example which I want to test: https://developer.samsung.com/galaxy-watch-develop/samples/companion/hello-native.html, it's dated for 2016, kind of old, but I haven't found anything newer.

For the development I'd like to use the Tizen5.5 emulator along with Android Studio's emulator.

I found a guidance on how to test my companion application with Tizen Emulator, but it didn't help.

It turned out that I need to install "Samsung Wearable Extension". So I did it:

enter image description here

However my emulator didn't get the Extension libraries, so Tizen Studio couldn't build these samples, as it couldn't find sap.h:

enter image description here

I searched for this issue online, and I found nothing. It seems Samsung Wearable Extension is not compiled for x86 emulators since Tizen version 3.0 (they only provided that for the real device which is not x86 surely).

So I ended up copying Tizen3's x86 builds of SAP, and then finally Tizen Studio could build this sample.

However my Emulator is not able to run the sample, as it doesn't have the SAP installed.

Then I found this site: https://github.com/Samsung/Tizen.NET/issues/54, where they managed to install sap onto emulator manually by these commands:

sdb push [tizen_sdk_path]\platforms\tizen-4.0\wearable\emulator-images\add-ons\sap /opt/usr/home/owner/sap
sdb shell rpm -i /opt/usr/home/owner/sap/sap-1.9.5-0.i686.rpm

Now my problem is that I don't have sap folder in add-ons for tizen4.0. I only have it for Tizen3.0.

So I tried doing this, but rpm -i fails:

sh-3.2# ls -all /lib/* | grep ncurses
lrwxrwxrwx  1 root         root               19 Nov  3 10:15 /lib/libncurses++.so.6 -> libncurses++.so.6.1
-rwxr-xr-x  1 root         root            71696 Oct 23 22:27 /lib/libncurses++.so.6.1
lrwxrwxrwx  1 root         root               20 Nov  3 10:15 /lib/libncurses++w.so.6 -> libncurses++w.so.6.1
-rwxr-xr-x  1 root         root            71696 Oct 23 22:27 /lib/libncurses++w.so.6.1
lrwxrwxrwx  1 root         root               17 Mar 13 18:20 /lib/libncurses.so.5 -> libncurses.so.6.1
lrwxrwxrwx  1 root         root               17 Nov  3 10:15 /lib/libncurses.so.6 -> libncurses.so.6.1
-rwxr-xr-x  1 root         root           169780 Oct 23 22:27 /lib/libncurses.so.6.1
lrwxrwxrwx  1 root         root               18 Nov  3 10:15 /lib/libncursesw.so.6 -> libncursesw.so.6.1
-rwxr-xr-x  1 root         root           247700 Oct 23 22:27 /lib/libncursesw.so.6.1
sh-3.2# rpm -i sap-1.7.54-0.i686.rpm
error: Failed dependencies:
        libncurses.so.5 is needed by sap-1.7.54-0.i686

As you can see, libncurses.so.5 is actually there (although I have linked it to libncurses.so.6.1.

So this is the first step: make my Tizen5.5 emulator contain the SAP library.

And the second step is to make my Android emulator to connect to Tizen5.5 emulator:

I managed to install SAccessoryService_Emul.apk to my Android Emulator, but I can't make it recognize my Watch Emulator, it always says "Disconnected" (not too surprising as the watch emulator is not having the SAP library):

enter image description here

I also did the adb command with adb -e forward tcp:8230 tcp:8230, -e because host is not an USB device but an emulator.

To make it sure I'm not missing anything I've installed Tizen 3.0 emulator (which obviously not able to run my application compiled with for 5.5), and this emulator actually has the SAP library installed.

So I went to step2, and opened up the "Emulator for Samsung Accessory" on the Android Emulator, but whenever it tries connecting with the Tizen Emulator it crashes:

enter image description here

Another very well designed Samsung Software.

Here is the error if anyone is interested:

2021-03-13 14:36:46.734 5124-5157/com.samsung.accessory.framework E/AndroidRuntime: FATAL EXCEPTION: SAP_DAEMON_HANDLER_THREAD
    Process: com.samsung.accessory.framework, PID: 5124
    java.lang.ArrayIndexOutOfBoundsException: Failed to update offset while sending the message! [offset=0; size=2]
        at com.samsung.accessory.session.SAMessage.decrementOffset(SAMessage.java:359)

ArrayIndexOutOfBoundsException: OMG.

For the record: Samsung guys: really shame on you! You managed to create the worst SDK of the world. Your samples have to be way easier to install!

Daniel
  • 2,318
  • 2
  • 22
  • 53

2 Answers2

1

F.Y.I
First of all, SAP is not supported for emulator. Unfortunately, it supports only real device.

You need to change the Architecture from x86 to arm in Platform Tab. and, you can choose samsung-sap and build codes without errors.

If you run/debug your application with emulator, Tizen Studio will change settings automatically from arm to x86. You will meet the build ERROR again!!

enter image description here enter image description here

Lunch Basketball
  • 432
  • 6
  • 10
  • I know all of this. So for development you have to use real devices all time constantly? This is the official method for 'howto develop companion applications? – Daniel Mar 16 '21 at 05:51
  • Using a real device for development is really painy. It takes at least 3times more to upload the new release to real device than to emulator. I can not believe every single developer uses real devices. – Daniel Mar 16 '21 at 05:53
  • Also, SAP _actually_ seem to be supported on Emulator before 4.0 version (up to 3.0). If you run an emulator (3.0 version) after you installed SAP, it will install the libraries after first startup. – Daniel Mar 16 '21 at 08:56
  • Complicated situation, The firmware of Gear devices = Tizen Platform Release + Samsung own Product features (SAP, Health, etc). Emulator in Tizen Studio doesn't have Samsung own Product features. – Lunch Basketball Mar 17 '21 at 00:05
  • Yepp, complicated, that's the reason of 100 points :) – Daniel Mar 17 '21 at 05:56
0

I had this same problem, even with all the Samsung SDK installed.

So, What I did was, Go to Project > Properties > C/C++ Build > Tizen Settings and check Samsung-sap option.

enter image description here

That solved the fatal error: 'sap.h' file not found error

Sreeram Nair
  • 2,369
  • 12
  • 27
  • I have no "samsung-sap" option there for Tizen 4.0 or Tizen 5.5 when building for x86-based emulator which is the question. – Daniel Mar 15 '21 at 18:55
  • Also your answer seems to done on Mac, and I was clearly mentioned that I'm hunting the solution for Windows10, sorry. – Daniel Mar 15 '21 at 18:56
  • Also, solving the "missing SAP during build" won't solve the missing SAP on the Emulator nor does it solve the problem with "testing companion application with Android Emulator". – Daniel Mar 15 '21 at 18:57