Android Environment Configuration Sencha Touch

Source: Internet
Author: User

Transfer from http://www.phonegap100.com/portal.php?mod=view&aid=19

As part of your development, the Sencha Touch framework developed for Android devices should be tested in an Android virtual machine. This blog discusses how to install and use an Android virtual machine, using the command line or the Sencha architect Builder for Sencha touch development.
The number of Android smartphones sold and used recently surpassed those of iOS smartphones. (published in an article in the April 2013 Time magazine).
Many Sencha touch developers are targeting the Android platform. This blog will show you how to build an Android development environment from beginning to end. The and path in the article is on Mac OS, the process on Linux is almost the same, and the process of Windows platform is very similar.

1. Install the Android SDK tool


Summary
Install the Android SDK tool: Download the appropriate files for your operating system.
Detailed
On the download page, click on the "Download for other platforms" drop-down menu to download the "SDK Tools only" ZIP file for your operating system. (for Windows, download the zip archive instead of the Installer.exe installation file).
What you are downloading is not the SDK itself, but a compressed file containing the rest of the SDK installer. In the next section we will use the SDK tool to download the real virtual machine.
Unzip the Android SDK tools into your home directory under the "Bin" folder, which may need to be created yourself.
Mac OS
For Mac OS, save the file to/users/username/bin (create it yourself if the bin folder does not exist). The full path to the Android SDK on your Mac is/users/username/bin/android-sdk-macosx/.
Linux
For Linux, save the file to/home/username/bin (create it yourself if there is no "bin" folder). The full path to the Android SDK on Linux is/home/username/bin/android-sdk-linux/.
Windows
If you are using Windows 7, Windows will store your personal files in the C:\Users\username directory. If you have installed Sencha CMD (see below), then the C:\Users\username\bin directory directory has been created for you, and if not, you can create it yourself. Unzip the Android SDK to the Bin folder. The full path for the Windows,android SDK is C:\Users\username\bin\android-sdk-windows.

2. Installing an Android virtual machine


Summary
Install an Intel-based Android virtual machine using the Android SDK Manager that you just downloaded.
Detailed

Under the tools subdirectory of the Android SDK directory, you can find an executable file called "Android". Double-click it to run Android SDK Manager.

Remove the tick next to "Android 4.2.2 (API 17)" So that all selected options in this section will be canceled. The only option you need to choose is "Intel x86 Atom System Image". If you want, you can keep the Platform tools and Build-tools, which are selected by default.
Since we're using Sencha touch to develop Android apps, we don't need anything else.
The following is the final step to complete the installation:

    1. Click "Install 4 packages ..." To download and install the package you selected.
    2. Click on the name of the package and click on "Accept License" to accept the license.
    3. The progress bar at the bottom will show the installation progress, please wait until all the packages are installed.
3. Configure and launch the Android virtual machine

Summary
To test the virtual machine we downloaded, we will configure it at the first run and then start the virtual machine to see if the virtual machine is working properly.
Detailed
After downloading all the packages in the previous step, select "Tools→manage AVDs ..." on the Android SDK Tools menu bar.

A dialog box will appear displaying the Android virtual device that you have built. If this is the first time you run this option you will not see any virtual devices. Click "New ..." To create a new virtual appliance.

Fill in the name of the virtual machine (name), device type (type of devices), and API level (this article uses API levels 17 i.e. Android 4.2.2). Also make sure you check the "Use Host GPU" option. Click OK to make these settings effective and click OK on the Device Information summary screen.

When you see a green tick in front of your first Android virtual device, you've configured your first Android virtual machine. Click Start ... on the right side of the dialog box to start the virtual machine. Click "Launch" in the next window.

If the installation is not faulted, the Android virtual machine will start. Depending on the computer configuration, the boot process may take several minutes. See the following interface to show that your virtual machine has been started.

Click that circle to see the software that has been installed on your virtual machine. If you have done this, you have correctly installed and configured your Android virtual machine.

Additional steps for 64-bit Linux systems
The Android emulator file is a 32-bit binary file. In order for your 64-bit Linux system to run 32-bit files, you need to install 32-bit libraries on your Linux version. On most Linux systems, it is not installed by default.
If you get an error message like "Emulator:file not found", even if you see the emulator file in your "Tools" directory, also install the 32-bit loader on your 64-bit Linux system.
Ubuntu/debian: Execute "sudo apt-get install ia32-libs"
Red Hat/fedora: Please read the documentation
Other versions of Linux: Please google search for "the" Loader for "system" or other similar information

4. Generate Android Certificate

Summary
Creates a certificate to use when downloading a program to an Android virtual machine or testing it on a real machine.
Verbose
To create a certificate that your Android virtual machine can use, you need to use the "Keytool" program in Java, so you should have Java SE 1.6 or later installed on your machine. If you're using a Mac, this is already installed, and the Windows machine is probably preinstalled with Java.
Open a terminal (Terminal) or command prompt to enter "Keytool". If this command is not found, you may need to access java.com to download Java SE 1.6 or later.
For simplicity, we set up the private key warehouse (KeyStore) in the Android SDK directory and set the private key warehouse (KeyStore), alias (aliases) and password (password) to "Android1". (For a real certificate you cannot set such a simple and obvious private key warehouse and password, but in order to maintain the simplicity of the sample demonstration we did so.)
The following is what is displayed in the terminal:

$ pwd/user/username/bin/android-sdk-macosx$ keytool-genkey-v-keystore android1.keystore-alias android1-keyalg rsa-k  Eysize 2048-validity 10000Enter keystore Password: (I entered "ANDROID1") what's your first and last name?  [Unknown]: Patrick Chuwhat is the name of your organizational unit?  [Unknown]: Trainingwhat is the name of your organization?  [Unknown]: Senchawhat is the name of your city or Locality?  [Unknown]: Redwood Citywhat is the name of the your state or province?  [Unknown]: Californiawhat is the Two-letter country code for this unit?  [Unknown]: usis cn=patrick Chu, ou=training, O=sencha, L=redwood City, St=california, c=us correct? [No]: yesgenerating 2,048 bit RSA key pair and self-signed certificate (SHA1WITHRSA) with a validity of ~ days fo R:cn=patrick Chu, ou=training, O=sencha, L=redwood City, St=california, c=usenter key password for <android1> (R Eturn if same as KeyStore password): [Storing android1.keystore]$


So far, you've got a file called "Android.keystore" that contains your credentials. You need to use this file to package the Sencha touch program to the cost of Android apps.

5. Edit Packager.json

Summary
Edit "Packager.json" to reflect the Android virtual machine environment and the details of the certificate file you generated above.
Detailed
In this step, we will generate an example of the Sencha touch app, so we have something to import into the Android virtual machine. To complete this, I will make the following assumptions about your Sencha touch environment:
The root directory of your local Web server is a folder called "Htdocs". If you are using XAMPP to install Apache this is the default.
Your Sencha touch file should be in the "HTDOCS/TOUCH2" directory.
You have installed the Sencha CMD. In order to test, enter "Sencha" in the terminal (Terminal) or Command Prompt window (commands prompt). If you see the Sencha cmd Help interface, the instructions Sencha cmd have been installed. If no command is found, install Sencha CMD.
Go to the "HTDOCS/TOUCH2" directory and enter the following command:
Sencha Generate App--name Androiddemo--path. /demo
For Windows, the path is ". \demo "
It doesn't matter if the Htdocs/demo directory doesn't exist--Sencha cmd is created automatically. When these commands are executed, you will get a simple but complete sencha touch application. If your Web server is working, you can run it in Http://localhost/demo.

In order to tell this application specific Android environment, we need to modify "Htdocs/demo/packager.json" this file. These are common properties that need to be modified by the various platforms:
"ApplicationID": "Com.demo.AndroidDemo",/* (this must include at least dual-use point delimited portions) */
"platform": " Androidemulator ",
" Certificatealias ":" Android1 ",
" Certificatepassword ":" Android1 ",
" Androidapilevel ": "+",
Mac OS
specific properties for Mac OS:
"Certificatepath": "/user/username/bin/android-sdk-macosx/android1.keystore",
"Sdkpath": "/user/username/bin/android-sdk-macosx",
Replace "username" for your own user name
Linux
Linux specific properties:
" Certificatepath ":"/home/username/bin/android-sdk-linux/android1.keystore ",
" Sdkpath ":"/home/username/bin/ Android-sdk-linux ",
Replace" username "with your own user name
for specific properties of Windows
Windows:
" Certificatepath ":" C:/user/username /bin/android-sdk-windows/android1.keystore ",
" Sdkpath ":" C:/user/username/bin/android-sdk-windows ",
Replace" Username "for your own user name
Yes, you can also use a forward slash
in your Windows path to save your changes to the file.

You're almost done! Now all we have to do is run our program on the Android virtual machine. Follow these steps:
Start your Android virtual machine. When Sencha cmd tries to send a program file, the virtual machine must be running.
Go to the "Htdocs/demo" directory (your application's root directory, where Packager.json is).
Input: Sencha app package Run Packager.json
(Note: To ensure that Sencha cmd works, you must add your Java executable to your environment variable)
If you are lucky enough (and you need patience), you should see the sample program running on your Android virtual machine! congratulations!
In the sample program, click on the tabs at the bottom to switch to a different interface.

Summary
The hardware accelerator is installed for the Android emulator to improve performance. This step is highly recommended.
Discuss
When you run your Sencha Touch program in your Android emulator, you may notice that it's running "lazy" (I think it's just the most polite thing to say). Because this simulator is completely software-implemented, it is always hang.
But if you're running on an Intel-based Mac or a Windows machine, you might have already used Intel drivers for the Android emulator that provide hardware acceleration, like VMware or hyper-V virtual machines that get hardware help. Your Intel processor has to support Intel Virtualization Technology (VT) in order to drive normal operation. Intel's name for this package, Hax, is "hardware accelerator" shorthand.

Note: You will notice that in the Android Package SDK tool, HAXM is listed at the bottom as a possible installation. Install Hax in this way I have some problems. However, you can go to the link above and install Hax from that page.
Note: If you are running Hyper-V on your PC on Windows 7, then for Intel hardware acceleration for your use, you will have to disallow the use of Hyper-V. Hyper-V Locks virtual attributes for use on its own, and therefore prevents other virtualization programs from running.

7. More Resources


Chrome Mobile Simulator: In Chrome, you can simulate touch events, screen resolution, device user agents, device orientation and positioning, all from within Chrome. This allows you to perform a lot of development and debugging in the host's browser, which is much faster, and then runs the app in the emulator for a daily test and completeness check.
Remote debugging apps on Android: Use Chrome on your console to debug your Internet app on your Android browser.

For more information
Do you have a good idea of the Sencha touch app, but you're not sure what's the best way to develop a Sencha touch app? Sencha Training provides you with a comprehensive programme of live, including Sencha touch and ExtJS, all year around the world. Secha Certified Teacher teaches you the simplest and best practices to get your Sencha Touch app and run it as fast as possible, including deployment under iOS and Android.

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

I configured according to the above method, to the last error, prompt stbuild is no longer supported in CMD 5.

Prompt version of the issue to be resolved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.