ผลต่างระหว่างรุ่นของ "Preparing Android Development Environment"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
 
(ไม่แสดง 2 รุ่นระหว่างกลางโดยผู้ใช้คนเดียวกัน)
แถว 15: แถว 15:
 
== Creating Your First Application ==
 
== Creating Your First Application ==
  
Test your ADT bundle installation by creating a simple application using the steps in http://developer.android.com/training/basics/firstapp/creating-project.html.
+
Test your ADT bundle installation by creating a simple application using the steps in http://developer.android.com/training/basics/firstapp/creating-project.html.  This project contains enough source files to make a runnable application.
 +
 
 +
The Youtube video https://www.youtube.com/watch?v=Z149x12sXsw provides great details of what each of these source files does.
  
 
== Running Your Application ==
 
== Running Your Application ==
แถว 25: แถว 27:
 
* On Windows, make sure the USB driver for your device has already been installed.  See http://developer.android.com/tools/extras/oem-usb.html for more details and download links.
 
* On Windows, make sure the USB driver for your device has already been installed.  See http://developer.android.com/tools/extras/oem-usb.html for more details and download links.
 
* Plug your mobile device to your machine.
 
* Plug your mobile device to your machine.
 +
* Enable USB debugging on your device.  This option can be found in Settings > Applications > Development (for Android <= 3.2), or Settings > Developer options (for Android >= 4.0).  However, for Android 4.2 or newer, this option is hidden.  Quoted from Android Developers website:
 +
<blockquote style="color: green; padding: 10px; border: dotted thin grey;">
 +
Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.
 +
</blockquote>
 
* On Eclipse, choose Run as > Android Application.  Then choose the device from the device list panel.  Eclipse will install your application on your device and start it.
 
* On Eclipse, choose Run as > Android Application.  Then choose the device from the device list panel.  Eclipse will install your application on your device and start it.
  

รุ่นแก้ไขปัจจุบันเมื่อ 17:02, 30 มีนาคม 2557

To prepare your machine for developing a native Android application, you will need Eclipse IDE with the ADT (Android Developer Tools) plugin, and Android SDK tools. The most convenient way is to install the ADT bundle, which includes a version of the Eclipse IDE with built-in ADT.

Downloading and Installing JDK

Eclipse requires Java Development Kit (JDK) and Java Runtime Environment (JRE) to operate. Follow these steps to download and install the latest version of JDK, which also includes a version of JRE.

Downloading and Installing ADT bundle

  • Download the ADT bundle from http://developer.android.com/sdk/index.html
  • Extract the ZIP file adt-bundle-<os_platform>.zip into an appropriate location, such as C:\android
  • Open the adt-bundle-<os_platform>/eclipse/ directory and launch eclipse

Creating Your First Application

Test your ADT bundle installation by creating a simple application using the steps in http://developer.android.com/training/basics/firstapp/creating-project.html. This project contains enough source files to make a runnable application.

The Youtube video https://www.youtube.com/watch?v=Z149x12sXsw provides great details of what each of these source files does.

Running Your Application

You have two choices to test your application: on an actual device and on an emulator.

Running Application on a Real Device

  • On Windows, make sure the USB driver for your device has already been installed. See http://developer.android.com/tools/extras/oem-usb.html for more details and download links.
  • Plug your mobile device to your machine.
  • Enable USB debugging on your device. This option can be found in Settings > Applications > Development (for Android <= 3.2), or Settings > Developer options (for Android >= 4.0). However, for Android 4.2 or newer, this option is hidden. Quoted from Android Developers website:

Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.

  • On Eclipse, choose Run as > Android Application. Then choose the device from the device list panel. Eclipse will install your application on your device and start it.

Running Application on an Emulator

  • First, create an Android Virtual Device (AVD) by clicking the menu Window > Android Virtual Device Manager.
  • In the Android Virtual Device Manager panel, click New.
  • Fill in the details for the new AVD. For example,
    • Name: My Tab Emulator
    • Device: 10.1" WXGA (Tablet) (1280 x 800: mdpi)
    • Target: Android 4.4.2 - API Level 19
    • CPU/ABI: ARM (armeabi-v7a)
    • Skin: HVGA
    • SD Card Size: 64 MiB
    • Emulation Options: Snapshot
These details can be changed later on.
  • Click OK to create your AVD.
  • Back to the Android Virtual Device Manager panel, select the newly created AVD and click Start.
  • On Eclipse, choose Run as > Android Application, then select the desired AVD that appears on the device list panel.