Adding Sony Android SDK in Android Studio

Today I started experimenting with the Sony SDK to add floating windows (Small Apps in the Sony lingo) capabilities to my app. All the documentation I found was for Eclipse and, apparently, nobody thought of documenting how to use it with Android Studio.

So, here are my findings after a lot of struggle. Beware, I am not sure this is the correct way to do it, but it works! At least for me. :)

Downloading the Sony SDK

This is the easy part, as it is quite clearly explained in the official Sony Developer site. You just need to open the Andsoid SDK Manager from Android Studio (the green android sitting on a grey box with a down-facing arrow in the toolbar), add a custom source and install it.

Adding the SDK to a project

Once you have created the application project, just press F4 (shortcut for “Open Module Settings”). In the Window that opens you should have, on the left, the default “SDK Location”, “Project” and “app” settings categories.

Just press the green plus icon in the top left corner. A new window opens, prompting you to select what to add.

Sony SDK components come as jar files, and they are not included in the main list. Just click the small “More modules” at the bottom and scroll until you find “Import .JAR or .AAR Package”, then select it and press “Next”. You will be presented with a rough window asking you for a File Name and a Subproject Name. Just press the “...” button in the top right and go to where you installed the Android SDK, then dig to find the Sony parts.

In my case, the SDK is at ~/android/sdk and the Sony components are at ~/android/sdk/add-ons/addon-sony_add-on_sdk_3_0-sony-19/libs/. Just select the one you need. As of today there are three: smallapps (for floating windows apps), camera.addon (to... wait for it... create addons for the camera app) and remotecontrol, to use the IR port on some devices.

Once selected, Android Studio will autocomplete the second field with the module name, and you just need to press “Finish” to add it to your project. It should now appear in the list on the left.

The last step is to inform the app that the library is provided and should not be compiled.

Click on “app” in the left list, then on “Dependencies” in the tabbed list appearing on the top. It should show at least “{dir=libs, include=[*.jar]} and maybe an android support module. If the list does not include the Sony module, press the green plus button in the top right, then, in the popup list, select “Module dependency” and select the Sony module.

It should appear in the list, but with Scope set as Compile. Just click on “Compile” and select “Provided” in the popup.

Now you can use the provided classes in your project.