Step by step to created Tizen app – This post documents the process of installing the Gear 2 sdk’s , running and testing the Hello World App for Samsung Gear 2 which is based on Tizen. No direct Step-By-Step tutorial is available on the Samsung Gear website and the Getting Started document can be fairly difficult to follow hence this tutorial. Even more confusing, especially for developers new to android and Samsung app development is “how to test the app in a simulator” especially if you do not have a Samsung device and gear smartwatch.
Clearing up a few Misunderstandings
– Samsung Gear 2 and Samsung Gear 2 Neo are different from the original Samsung Gear in that they run the tizen OS as opposed to the android OS on the orginal Samsung Gear.
– The Samsung Gear SDK for android was never really released. While there are a few other samsung accessory services (e.g s pen sdk, group play, AdHub) that are android based, Gear 2 apps are different and must be developed using the Tizen IDE (more on this below)
– In developing and testing connected apps for Samsung Gear, you can either use a real Samsung device and a real gear 2 device , or a real Samsung device and the gear emulator. Currently, using an android emulator and a gear emulator is not supported. More on this is explained below.
See: How to Access Sample Apps and Code for Gear 2
– The Tizen OS is different from the Tizen for Wearable OS. While the Tizen OS is a full featured mobile OS with features like wifi, carrier mobile service support, C++/C native app + HTML5 support, the Tizen for wearable currently supports only HTML5 and no wifi or carrier service support.
Understanding the Structure of a Samsung Gear App
Samsung gear apps follow the producer consumer model where the producer is an app running on a Samsung Host device (phone or tablet) , and the consumer is a widget app running on the Samsung Gear smartwatch. More explanation from the Samsung device below.
The host device runs an application called the Gear Manager, which communicates with the WearableManagerService running on the Gear. Applications intended for Gear has two parts, one of which runs on the host, called the Host-side Application. This installed application will include an application widget intended for the wearable device, called the Wearable-side widget. The Host-side application generally serves a “provider” function, while the Wearable-side widget generally serves a “consumer” function (these functions will be described in more detail later). During the installation of an Host-side application which contains a Wearable-side widget, the Gear Manager sends the Wearable-side widget to the WearableManagerService on the wearable. The WearableManagerService then installs the Wearable-side widget.
Whilst there is the opportunity to develop applications that take advantage of these two parts, you still have the choice to develop 3 types of apps . Linked Apps, Integrated Apps, and Standalone Apps.
Linked (Master-Follower) Type
The linked Gear application is not included with the general host application. You must install the general host application and the wearable-side widget separately. This is useful if the host application is optional for the gear app.
In an integrated Gear application, the host-side APK contains the app that runs on both the host devices and the wearable side gear app. When you download an integrated Gear application, the general host application in the host-side APK is installed simultaneously with the wearable-side widget. You should use this type of development if your wearable-side app requires the host portion. E.g a news feed app on a smartwatch cannot connect to the internet and must rely on the host side app to “feed” it the news updates.
You can use the standalone type, such as a Clock app, when your Gear application does not need a general host application, and can operate independently.
Now that we know a Gear app has two parts, the question is how do we develop each part. Turns our you can use your usual Eclipse environment for developing the host device app (an android ), and you also use the Tizen SDK to build the consumer widget running on the smartwatch. We will illustrate this using the HelloAccessory sample application on the samsung developer website.
Step 1 – Download and Install the SDKs
For the host app development, I suggest you get a copy of eclipse IDE for Java (I already had one) and install the Samsung Accessories plugin . You can use the install new plugin eclipse menu option (Help > Install New Software) and add the Samsung Accessories repository link – http://developer.samsung.com/smsdk/repository/samsung-sdk . Install the entire content of the repository
Next download and install the tizen wearble sdk install Manager . MAKE SURE YOU DOWNLOAD THE SDK FOR WEARABLE AND NOT THE REGULAR TIZEN SDK … I made that mistake earlier.
However, I still ran into the following error while installing Tizen on a windows 8.1 64 Bit Machine
cannot execute java even if it was installed
After verifying the JAVA HOME variable, path variable and ensuring that any x86 version of java on my machine was uninstalled, it still gave the same error. I however got it to install using some strange hack I found here.
– First, open the windows command line console (cmd) and navigate to \AppData\Local\Temp\tizensdk_2014xxxxxxx . This folder is usually under Users\YourName\AppData …..
– Next, try to locate the downloaded tizensdk folder and install its jar using java commands.
– Type in: java -jar InstalManager.jar
And another error popped up ..
cannot find repository ..
To fix that, I did the following .
– Download the tizen wearable sdk image . This is different from the install Manager we downloaded above.
– Click on Advanced > SDK Image > Select the image you downloaded in the previous step . Next .. next … next
And that got it installed. On to the next step.
Step 2 – Import Sample Projects – HelloAccessory Sample
Download the HelloAccessory sample project that demonstrates sending a string between a samsung device and a gear. This zip folder contains a source folder with two sets of source code . Staying true to the producer consumer paradigm, the first source folder “HelloAccessoryConsumer” is for the gear device widget and should be imported into your installed Tizen SDK IDE as a project. The other folder “HelloAccessoryProvider” is an Android eclipse project for the host app running on the samsung device. You may import it into your eclipse IDE as an android application.
Step 3 : Build the Tizen HelloAccessoryConsumer Widget
After importing the HellowAccessoryConsumer into your tizen wearable IDE, right click on the project and select build. After successfully building the project, the HelloAccessoryConsumer.wgt is created .
This represents a standalone .wgt file than can be uploaded into your samsung Gear 2 and installed. To learn more about standalone apps , you can peruse the large collection of sample gear 2 sample apps that come with the tizen for wearable IDE.
See : How to install standalone wgt apps on a gear 2 device or emulator.
Step 4 : Build the Android Host Section Part.
Remember the three paradigms of apps (Linked, Integrated and Standalone) ? In this step we will be building the android host app that constitutes a part of the the linked and integrated type of apps.
Now copy the .wgt file which you have generated from your tizen project into the assets folder of your HelloAccessoryProvider android project and build it to generate an apk. The idea here is that after you install the HelloAccessoryProvider apk it automatically installs the consumer widget on a connected gear 2 device. The pre-condition is that gear manager must be installed on the device.
Step 5: Testing Your Gear-side app on Tizen Wearable Emulator.
As always there are two methods to test apps. Using live devices (Galaxy S5 and above) and a Gear 2 smartwatch, or using emulators. I’ll focus on how to get this done using emulators as I don’t have test devices at the moment.
First, we create a wearable emulator using the IDE connection explorer
Emulator Manager > Create New VM > Enter name etc … click the play button to launch emulator.
To run the consumer app, Right Click on the project > Run as Tizen Wearable Web Application . All running now!
See Also : Creating gestures for your Gear 2 apps (swipe, pinch, rotate, double tap, etc)
Step 6 : Set Up An Android Device to Communicate with the Tizen Emulator
Update : It appears the tizen emulator will ONLY communicate with Samsung Gear compatible devices . I have tried unsuccessfully to get this running on my trusty Samsung Galaxy s2 running CM11.
The Samsung Gear Compatibility list is :
Samsung Galaxy S5 / Galaxy Grand 2 / Galaxy Note 3 / Galaxy Note 3 Neo / Galaxy Note 2 / Galaxy S4 / Galaxy S3 / Galaxy S4 Zoom / Galaxy S4 Active / Galaxy S4 mini / Galaxy Mega 6.3 / Galaxy Mega 5.8 / Galaxy Note 10.1 (2014 Edition) / Galaxy NotePRO (12.2) / Galaxy TabPRO (12.2/10.1/8.4)
Now that we are sure the tizen emulator works, we’ll set up any android device to act as its host device. This devices may also be a real world android phone connected via usb .
Samsung provides some guidelines on how to get this done . There are three apk files you need to install on your android device . You can find them under – Applications for Emulator – on the Samsung Gear developer page . SAccessoryService_Emul.apk , SAFTCore_Emul.apkHostManagerForEmul.apk . Download and install them via ADB in this order . To do this, ensure you have added ADB to your system path, navigate to the extracted Applications for Emulator folder and type
– adb install SAccessoryService_Emul.apk .
Do this for all three files in the order above.
Now, launch the HostManagerforEmulator app which should now be visible in your app drawer list.
Next, enter the following command in adb
“adb –d forward tcp:8230 tcp:8230”
This should change the hostManager status to connected. Once this is done, you can now run the HelloAccessoryProvider apk in the host device and it should be able to communicate with the tizen emulator HelloAccessoryConsumer widget.
Testing Using the Samsung Remote Testing Lab
Another final way to test your app is to use the Samsung Remote Testing Lab . You will need to create a Samsung Account, and will be allocated an elaborate testing quota each day.
The Remote Test Lab service enables developers to access Samsung mobile devices through the web and to install and test applications on the devices. This is not only the most effective and easiest way to test the compatibility of an application with Samsung mobile devices but also the best way to cut down on hardware costs for test devices. Interaction with the device is performed over the network in real time allowing you to comprehensively test your application before distributing it.
A Few other Errors Encountered Along the Way and FAQ
Windows Critical Structure Corruption
The Tizen SDK installs intels hardware acceleration manager (Intel HAXM) and the idea is to help speed up the performance of the emulator. For some reason installing this leads to a blue screen of death (BSOD) while running the emulator and the error
WINDOWS CRITICAL STRUCTURE CORRUPTION .
I attempted to install a fix from intel that can be found here .. which caused the wearable emulator to just stop working. In the end I just uninstalled the intel haxm software from control panel. Emulator was slower, but BSOD did not happen again.
Problem Loading Perspective
Naturally, Tizen IDE crashed (because of the BSOD error above) while running the wearable emulator. After I launched the IDE, the tizen web perspective just didn’t load up again and gave an error.
problem loading perspective
To fix it, I deleted my workspace folder, closed and restarted the IDE.
If this does not work, delete the entire Tizen wearable sdk folder and re-install the IDE (using step 1 above). This means you have to perform all your imports again. You may back up your .metadata file in your workspace before a crash and replace it after a crash.
Can I Install the HostManagerEmulator apk on a Non-samsung Phone ?
As of the time when this article was written, it is not possible (based on tests I have run) to test your Gear 2 apps using a non-samsung-gear-compatible android host device. I used a Samsung Galaxy s2 running CyanogenMod 11. First I tried installing the apk’s using adb .. flat out didn’t work – “App Not Installed” . They I tried to brute force the installation by installing the apk’s sequentially in the android systems folder. Hostmanager actually got installed but kept crashing. Apparently there are a few dependencies only available on the Gear-compatible samsung devices. I have also asked and posted on the samsung developer forum and the current consensus is that it is not supported. For now, the best bet to test linked apps is to use the Samsung Remote Testing Lab.
What has been your experience ? Do you own a Gear compatible device and have successfully conducted tests ? Feel free to share your experiences below
Sources : http://denvycom.com/blog/step-by-step-guide-to-build-your-first-samsung-gear2-app-tizen/