반응형
반응형

Android Simulator Setup for Sencha Touch

 

http://www.sencha.com/blog/android-setup-for-sencha-touch/

 

Sencha Touch applications developed for Android devices should be tested in the Android simulator as part of your development process. This blog post discusses how to install and use the Android simulator, for Sencha Touch applications developed with either the command line tools or Sencha Architect.

The number of Android smartphones being sold and used has recently surpassed iOS smartphones. (This Time magazine article from April 2013 breaks down the numbers).

Many Sencha Touch developers are targeting the Android platform. This blog post will show you how to set up an Android development environment from start to finish. The screenshots and directory names are Mac-centric. The process for Linux is almost identical, and the process for Windows is very similar.

1. Install Android SDK Tools

Summary

Install the Android SDK Tools: download the proper file for your operating system.

Discussion

On the download page, click the dropdown for "Download for Other Platforms" and download the "SDK Tools Only" zip file for your operating system. (For Windows, download the zip file, not the installer.exe).

What you're downloading is not the SDK itself, but a zip file that contains the installer for the rest of the SDK. We will use the SDK tools to download the actual emulator in the next section.

Unzip the Android SDK Tools to the "bin" directory in your home directory, which you may have to create.

Mac OS

For Mac OS, save the file to /Users/username/bin (create the "bin" directory if it doesn't exist). The full path to your Android SDK directory on Mac is /Users/username/bin/android-sdk-macosx/.

Linux

For Linux, save the file to /home/username/bin (create the "bin" directory if it doesn't exist). The full path to your Android SDK directory on Linux is /home/username/bin/android-sdk-linux/.

Windows

If you're using Windows 7, Windows puts your personal files in the directory C:\Users\username. If you've already installed Sencha Cmd (see below), the C:\Users\username\bin directory has already been created for you, otherwise you can create it. Unzip the Android SDK under the bin directory. For Windows, the full path to the Android SDK is C:\Users\username\bin\android-sdk-windows.

2. Install the Android emulator

Summary

Using the Android SDK Manager (that you just downloaded), install the Intel-based Android emulator.

Discussion

Android and Sencha Touch

In the Android SDK directory, under the "tools" subdirectory, you'll find an executable file called "android". Double-click on it to launch the Android SDK Manager.

Android and Sencha Touch

Uncheck the box next to "Android 4.2.2 (API 17)". This will uncheck all the boxes in that section. The only box you need to check is "Intel x86 Atom System Image". You can leave the checkboxes next to "Platform tools" and "Build-tools" checked if you want.

Since we are using Sencha Touch to develop our Android apps, we don't need to install any of the other products.

Here are the final steps to finish the install:

  1. Click "Install 4 packages..." to download and install your Android packages.
  2. Click on the package headers, and click "Accept License".
  3. The progress bar at the bottom will show you the progress of the install. Wait until all your packages have been installed.

3. Configure and start up the Android emulator

Summary

To test our emulator download, we'll configure the emulator for its first run, then start it up to see if it's working properly.

Discussion

After all your packages have downloaded in the previous step, select the "Tools → Manage AVDs..." menu item in the Android SDK tools.

Android and Sencha Touch

A dialog will appear showing you all the virtual Android machines that you've defined. Since this is the first time that you've run this command, there are no machines shown. Click the "New..." button to define a new machine.

Android and Sencha Touch

Fill in the name, type of device, and the API level (17 in our case). Also, make sure the "Use Host GPU" checkbox is checked. Click OK to accept these settings, and click OK to accept the summary screen.

Android and Sencha Touch

You've configured your first Android emulator, and you should see a green check in front of your virtual Android device. On the right side of the dialog, click "Start..." to start up the emulator. On the following screen, click "Launch".

Android and Sencha Touch

If you've installed everything correctly, the Android emulator will start up. Depending on the speed of your machine, the startup process may take several minutes. When the emulator starts up, you should see the screen below.

Android and Sencha Touch

Click on the circle to see the applications that are already installed in this emulator. If you're able to see this screen, then you have installed and configured your Android emulator correctly.

Additional steps for Linux 64-bit

The Android emulator file is a 32-bit binary. To run 32-bit binaries on your 64-bit Linux system, you will need to install 32-bit libraries for your version of Linux. On many Linux systems, this is not done by default.

If you get an error message similar to "emulator: file not found" even though you can see the emulator file right there in your "tools" directory, then you have to install 32-bit loaders for your 64-bit Linux system.

Ubuntu/Debian: type "sudo apt-get install ia32-libs"

Red Hat/Fedora: read the docs

Other flavors of Linux: Google "<Linux flavor> 32 bit loader for 64 bit system" or something similar

4. Generate an Android certificate

Summary

Create a certificate to use when downloading programs to the Android emulator or testing on the physical Android device.

Discussion

To generate a certificate usable with your Android emulator, you will be using the "keytool" program that comes with Java, so you must have Java SE 1.6 or higher installed on your machine. This is already installed if you’re using a Mac, and is most likely already installed on your Windows machine.

From the Terminal or a command prompt, type "keytool". If the command is not found, you may need to go to java.com, and download Java SE 1.6 or higher.

For simplicity, we’ll create the keystore in the Android SDK directory, and we’ll set the keystore, alias, and password all to "android1". (For a real certificate you would not set such obvious values for the keystore and password, but we're trying to keep things simple for our demo.)

Here's what the dialog looks like:

$ pwd
/User/username/bin/android-sdk-macosx
$ keytool -genkey -v -keystore android1.keystore -alias android1 -keyalg RSA -keysize 2048 -validity 10000
Enter keystore password: (I entered "android1")
What is your first and last name?
  [Unknown]: Patrick Chu
What is the name of your organizational unit?
  [Unknown]: Training
What is the name of your organization?
  [Unknown]: Sencha
What is the name of your City or Locality?
  [Unknown]: Redwood City
What is the name of your State or Province?
  [Unknown]:  California
What is the two-letter country code for this unit?
  [Unknown]:  US
Is CN=Patrick Chu, OU=Training, O=Sencha, L=Redwood City, ST=California, C=US correct?
  [no]:  yes

Generating 2,048 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 10,000 days
    for: CN=Patrick Chu, OU=Training, O=Sencha, L=Redwood City, ST=California, C=US
Enter key password for <android1>
    (RETURN if same as keystore password):  
[Storing android1.keystore]
$

At this point, you have a file called "android.keystore" that contains your certificate. You will need this file to package a Sencha Touch app into a "native" Android application.

5. Edit packager.json

Summary

Edit "packager.json" to reflect details about the Android emulator environment and the certificate file that you generated above.

Discussion

In this step, we’re going to generate a demo Sencha Touch app, so we have something to load into the Android simulator. To do this, I'm going to make some assumptions about your Sencha Touch environment:

  • The root of your localhost web server is a folder called "htdocs". This is the default if you installed Apache using XAMPP.
  • Your Sencha Touch files are in the directory "htdocs/touch2"
  • You've already installed Sencha Cmd. To test, type "sencha" from the Terminal or command prompt. If you see a Sencha Cmd help screen, then Sencha Cmd is installed. If the command is not found, install Sencha Cmd

Change directory to "htdocs/touch2", and enter the following command:

  • sencha generate app --name AndroidDemo --path ../demo
  • For Windows, the directory is "..\demo"

It’s OK if the htdocs/demo directory doesn't exist -- Sencha Cmd will create it. When the command completes, you will have a simple but complete Sencha Touch application. If your web server is running, you can see it running at http://localhost/demo.

To tell this application about the details of our Android environment, we have to edit the "htdocs/demo/packager.json" file. Here are the properties that we need to edit, common to all platforms:

  • "applicationId": "com.demo.AndroidDemo", /* (this must contain at least 2 parts separated by periods) */
  • "platform": "AndroidEmulator",
  • "certificateAlias": "android1",
  • "certificatePassword": "android1",
  • "androidAPILevel": "17",

Mac OS

Properties specific to Mac OS:

  • "certificatePath": "/User/username/bin/android-sdk-macosx/android1.keystore",
  • "sdkPath": "/User/username/bin/android-sdk-macosx",
  • Substitute "username" with your username

Linux

Properties specific to Linux:

  • "certificatePath": "/home/username/bin/android-sdk-linux/android1.keystore",
  • "sdkPath": "/home/username/bin/android-sdk-linux",
  • Substitute "username" with your username

Windows

Properties specific to Windows:

  • "certificatePath": "C:/User/username/bin/android-sdk-windows/android1.keystore",
  • "sdkPath": "C:/User/username/bin/android-sdk-windows",
  • Substitute "username" with your username
  • Yes, you can and should use FORWARD slashes in your Windows path

Save your edits to the file.

You’re almost done! Now all we have to do is run our program in the Android emulator. Here are the steps:

  • Start your Android emulator. It has to be running at the time that Sencha Cmd attempts to send it the application's files
  • Change directory to "htdocs/demo" (the root of your application, where your packager.json file lives)
  • Type: sencha app package run packager.json

(Note: your Java executable must be somewhere in your path in order for Sencha Cmd to work)

If you're lucky (and patient), you should see the sample application start in your Android emulator! Congratulations!

Click on the tabs at the bottom to move between screens in the sample app.

6. (optional) Install Intel’s hardware acceleration drivers for the Android emulator

Summary

Install hardware acceleration for the Android emulator to improve performance. This step is HIGHLY recommended.

Discussion

While running your Sencha Touch program inside your Android emulator, you may notice that it runs a bit "sluggish" (the most polite term I could think of). Since the emulator is implemented completely in software, it’s always been slow.

However, if you’re running on an Intel-based Mac or Windows machine, you can use Intel drivers that provide hardware acceleration for the Android emulator, in the same way that VMWare’s or Hyper-V’s virtual machines are also hardware assisted. Your Intel processor has to support Intel’s Virtualization Technology (VT) in order for the drivers to work. Intel’s name for this package is HAX, short for "Hardware AXceleration".

You can download the software from this page.

The page also contains links to very detailed installation instructions for all supported platforms. After you install the software, you will notice that the Android emulator runs much faster.

NOTE: You’ll notice that, in the Android Package SDK tool, HAXM is listed at the bottom as a possible install. I've had problems installing HAX this way. Instead, go to the link above and install it from that page.

NOTE: If you are running Hyper-V in Windows 7 on your PC, you will have to disable it in order for Intel’s hardware acceleration to work. Hyper-V will lock up the virtualization feature for itself, thus preventing other virtualization programs from running.

7. More resources

Below I&rsquo've listed two useful Android development features that I don't have room to cover in this blog post.

  • Chrome Mobile Emulation:Within Chrome, you can simulate touch events, screen resolutions, device user agents, device orientation, and geolocation, all from within Chrome. This allows you to perform the bulk of your development and debugging in the host’s browser, which is much faster, and then run the application in the simulator as a once-a-day test and sanity check.
  • Remote Debugging on Android:Use Chrome on your host to debug web applications in your Android browser.
반응형
반응형

사람은 항상 잘못을 저지른 다음에 고칠 수 있고,
마음이 괴롭고 자꾸 생각에 걸려야 분발하며,
남의 안색에서 확인하고
남의 목소리에서 드러나야만 깨닫는다.
안으로는 법도 있는 대신과 보필하는 선비가 없고,
밖으로 적국과 외환이 없으면
이런 나라는 항상 망하게 되어있다.
사람은 우환에 살고 안락에서 죽는다.
-맹자

 

변화에 능한 자 만이 살아남는다고
역사는 우리에게 가르칩니다.
그러나 혁신은 이대로 가다가는 생존이 불가능하다는
절대적 위기의식 속에서만 시작될 수 있습니다.
변화로 인해 잃는 것은 실제보다 크게 느끼고
변화로 인해 얻을 수 있는 것은 불확실하기 때문입니다.

반응형
반응형


당신의 재능은
사람들 머리 속에 기억되지만,
당신의 배려와 인간적인 여백은
사람들 가슴 속에 기억됩니다.
가슴으로 당신을 기억하는 사람들은
모두 다 당신 편입니다.


- 이철환의《못난이만두 이야기》중에서 -


* 외롭습니까?
너무 외로워 마십시오.
앞서거니 뒤서거니 가는 인생길,
언제 어디선가 평생 가슴으로 기억되는 길동무를
만나는 행운의 시간이 분명 있을 것입니다.
그럼요. 당신이 먼저 가슴을 열면
그 뒤에 만나는 길동무마다
모두가 당신 편입니다.

반응형
반응형
보이지 않는 과녁은 맞출 수 없으며, 이미 존재하지 않는 목표는 볼 수 없다. - 지그 지글러 -

 

반응형

'아침편지' 카테고리의 다른 글

함께 산다는 것  (0) 2013.06.25
모두 다 당신 편  (0) 2013.06.24
반창고 아프지 않게 떼는 법  (0) 2013.06.22
주면 줄수록 내가 더 행복해 진다.  (0) 2013.06.21
더 잘 살기 위해서  (0) 2013.06.21
반응형
https://github.com/sdeering/gumby2-backbone-bootstrap

 

Gumby2 Backbone Bootstrap

I have created a new repo which combines Gumby2 CSS Framework with Backbone.js.

Barebones Demo

Why Gumby2?

* Gumby2 has awesome touch event support.
* Gumby2 is powered by SASS.
* more -> 

Why Backbone?

* Speed, it supercharges your web app.
* Data, Logic and View separation.
* Dynamic template loading and execution.
* more -> 

Features:

* Gumby2 Framework - Bootstrap UI, SASS, HTML5BP, Touch Support.
* Backbone Framework - Web App Models, Views/Templates 
* more -> 

Todo:

* Load scripts using require.js
* Document build process
* Document SASS usage
* more -> 
반응형
반응형

Gif.js — JavaScript GIF encoding

Gif.js is a full-featured GIF encoder built in JavaScript that runs in your browser. Images are generated in the background using web workers.

gif.js

 

Full-featured JavaScript GIF encoder that runs in your browser.

Download & Docs on GitHub

Usage

var gif = new GIF({
  workers: 2,
  quality: 10
});

// add a image element
gif.addFrame(imageElement);

// or a canvas element
gif.addFrame(canvasElement, {delay: 200});

// or copy the pixels from a canvas context
gif.addFrame(ctx, {copy: true});

gif.on('finished', function(blob) {
  window.open(URL.createObjectURL(blob));
});

gif.render();
반응형

+ Recent posts