Outils pour utilisateurs

Outils du site


issue102:c_c

Ceci est une ancienne révision du document !


I recently received a BQ Aquaris E4.5 device running Ubuntu. Part of the reason for getting it was a promise to write a series of articles about developing for the phone. This will be part 1, covering setup and a basic ‘hello world’ program.

Install the SDK

Ubuntu released the Ubuntu SDK in order to make development easier. I will be focusing on this program for the series. If you’re averse to SDKs, I would imagine it’s possible to still develop for Ubuntu, but I won’t be covering it in this series.

Adding the Repository

sudo add-apt-repository ppa:ubuntu-sdk-team/ppa

This command will add the official ubuntu-sdk PPA, to allow you to easily get the newest packages.

Install the package

sudo apt update && sudo apt install ubuntu-sdk

This command updates the package list, and immediately afterwards installs the ubuntu-sdk package.

The official install page notes that anyone running a development version of 15.10 should ensure their packages are all up-to-date, before installing ubuntu-sdk, with a “sudo apt dist-upgrade”.

Launch the Application

ubuntu-sdk

Or, just find and click on the sdk icon.

Once the application has launched, you’ll want to click on “Create a New Project”, or File → New File or Project. For the sake of the Hello World program, I’ve chosen an HTML5 App. If you want to experiment with anything else, feel free to do so.

Create your Project

The SDK will first ask you for a name and a save location. I chose HelloWorld and ~/Ubuntu SDK Projects/, but you’re welcome to choose anything you want.

The next page will ask for personal information - your nickname, full name, email, the app name, and the framework you want to develop for. I chose the ubuntu-sdk-15.04 framework (as I am running 15.04).

Build Targets

By default, there is only the Desktop kit available. So you’ll need to choose “create new kit”, and choose “armhf” if you’re planning to run it on a phone. Once you select the architecture, it will prompt you for your password, and begin installing the kit. Note: If you’re running this in a virtual machine (for any reason), or a small partition, make sure you have more than 10GB dedicated to the hard drive. (Using the Ubuntu base, updates, the SDK, and the kit install, I ran out of space on my test 10GB partition).

Note: if you don’t want an emulator, and want to run it only on a physical device, you can skip this step.

Post Kit Creation

The wizard then simply asks what Kit(s) you want to use, and asks about version control. I enabled both Desktop and the armhf kit I just created, and skipped over the version control.

The Hello World Application

As it turns out, the basic HTML5 app is already a Hello World application. As such, we won’t be doing any actual coding. Instead, I will focus on running the device locally, and on the physical device. If you want to adjust the HTML, feel free.

Desktop

If you look in the lower left of the SDK window (shown below), you’ll see an image of a Desktop (or an Ubuntu logo, depending on which kit you selected). Below that are two green arrows, and a hammer. The first green arrow is “run”, the other is “debug”, and the hammer is “build”. The Desktop kit is used to run the application within Ubuntu, in a separate window. So, if you hit the “run” button, you should see something similar to the below screenshot (assuming you used an HTML5 App).

Ubuntu Phone (Emulated)

In order to run it on an Ubuntu Phone, you’ll need to create an emulator. To do so, go to Devices, and click the large plus sign. There, you’ll need to give it a name (without spaces), choose the architecture, as well as the Ubuntu image you want. I chose bq-stable over devel, since my goal is to test it on a physical bq device later.

Once you enter the information, it will prompt you for a password, and then begin creating the emulator.

Once the emulator is created, simply click on the Icon above the green arrow, and select (with your arrow keys) the kit you want to use. In the case of the example, it’s the armhf kit you want. Then clicking “run” will launch the emulator, and eventually load the app into the emulator.

Ubuntu Phone (physical)

The Ubuntu Devices section from the emulated section will also display any usb connected Ubuntu devices. However, my Aquaris E4.5 was not recognized at first. It turns out I had forgotten to enable developer mode. On the phone, go to Settings → About This Phone, and then Developer Mode. Make sure there is a green checkmark. Then plug it in. You can check to see if it’s connected properly by running adb devices in the list. Or lsusb (to see if the device is even recognized). It should also appear as an MTP device. Once the physical device is connected, switch to the Ubuntu Devices panel, and ensure it’s listed here too. Also, make sure it’s unlocked. If it isn’t, you’ll see something similar to this in your log: arch:error:closed.

Once it appears in your Ubuntu Devices panel, it will show a message about frameworks. Just allow it to automatically select a framework, and you’re done. This will create a new Kit called “Ubuntu Device”. In order to build and run your application on the phone, you need to click on the tab/icon for “Projects”. There, you’ll want to click on the button “Add Kit” (just above the hammer icon), and select the Ubuntu Device from the menu. Once the kit is added, you must select it (the icon above the green arrow in the bottom left), and run the project. This will then open the app on your phone.

In order to stop the application, click on “Application Output” on the bottom of the window. There, you can click on a red square to stop the application from running. If you forget to do so, the Ubuntu SDK will warn you about it, and offer to force-quit the application.

Wrap-Up

That was it for this month. Now that we’ve gotten the basics out of the way (running applications), we’ll be ready to start programming! If you have any questions, requests, suggestions, or just want to say hi, I can be reached at lswest34+fcm@gmail.com.

issue102/c_c.1446400330.txt.gz · Dernière modification : 2015/11/01 18:52 de auntiee