Developing Apps for Samsung Gear 2

During the last few weeks, I developed an application for my Gear 2 device. It took me some effort to get around several obstacles. Below I'm sharing my experience. I hope this will help others as well.

TIZEN IDE vs. TIZEN IDE for Wearable

To develop apps for a Gear2 device you will need to install the Wearable IDE. The "normal" Tizen IDE will also let you develop and build wearable apps, BUT you will most likely run into trouble when you want to debug or deploy such an application.

Also misleading is the certificate generation process. The normal (non-warable) IDE supports this directly from the GUI for Security Profiles. The wearable IDE does support this in a different way. The online help for wearable does explain this pretty well (The other one does not...).

On the following screenshot you can pretty clear how the right IDE looks on Mac. If you use the normal IDE the "for Wearable" part is missing in the menu-bar.

Screenshot Tizen IDE for Wearable on Mac OS


Security Profiles

Going to "Tizen IDE for Wearable" -> "Preferences" shows the dialog for the profiles:
TIZEN IDE for Wearable - Preferences
On the wearable IDE this dialogue is only needed when you want to change between different profiles. You must have a profile in order to run an application. In order to achieve this, you need to go through the process of obtaining a certificate from Samsung:



Pressing the Icon in the toolbar of the IDE will show the certification request dialogue:

Certificate Generation Dialogue
Here it is important to enter the DUID, if you want to debug (or even run) on your physical device. If you do not have a device, you can obtain a virtual device ID from Samsung (http://developer.samsung.com/samsung-gear).

After finishing the dialogue, you should have the request file under <path to your ide>/tizen-wearable-sdk-data/keystore/certificate-request.xml. You need to send this file to Samsung using OpenPGP for encryption. It appears that Samsung processes these requests during business hours in Korea. Depending on where in the world you are located, you should plan for at least one night response time. On weekends you may not expect a response.


The response from Samsung should contain the "certificate-registration.xml", if you have submitted the request correctly. This file needs to be imported using the IDE by using the "Register Certificate" function. 


After the import you may want to make sure that the new imported data is the active one in the above mentioned Preference Screen for Security Profiles.

Also you must copy the received file to your device (/home/developer). This can also be done by using the IDE when the device is attached.

At this point you should be able to run and debug apps on the Samung Gear.


INVALID_SIGNATURE

Reason for "INVALID_SIGNATURE":
a) Missing Settings for Security Profile: This is the most obvious one, but may not always lead to a solution. There are other reasons.
b) Project under Version Control: It seems impossible to have wearable projects in version control. This is quite a drawback. No idea how to use the repository functions in Eclipse in this context. Reason: see next item.
c) Additional files: I had a ./tmp directory in the project. It was not shown in the IDE, however, when a wgt file is assembled, the signature process seems to recognize to not sign extra files. These files are still packed into the wgt. On the device, there is then the signature missing for these files. Version Control also adds files to a structure. This then breaks the signature validation process on the device.

PRIVILEGE_VIOLATION

It appears that it is possible to debug applications in the emulator without having a Samsung signed certificate. When debuging or running on a device, the violation occurs. It looks like an app on a device requires the certification from Samsung including the device UID (DUID).

In other sources it is recommended to comment the privileges section from the config.xml:

    <tizen:privilege name="http://developer.samsung.com/privilege/accessoryprotocol"/>

Commenting out this line from config.xml will avoid the error message. An application requiring functionality covered by privileges will produce security errors and will not work. So this is not really helpful.

You need to go through the certificate generation process, send the generated XML to Samsung. The response file needs to be copied to the real device (to /home/developer). Then you should be able to run an application requiring privileges.