Android Studio: Hello World

From OnnoWiki
Jump to navigation Jump to search

Bagian ini mengajarkan Anda bagaimana membangun aplikasi Android pertama Anda. Anda akan belajar cara membuat sebuah proyek Android dan menjalankan versi debuggable dari app. Anda juga akan belajar beberapa dasar-dasar desain aplikasi Android, termasuk bagaimana membangun antarmuka pengguna yang sederhana dan menangani input pengguna.

Set Up Environment Anda

Sebelum kita mulai latihan, pastikan development environment telah di set dengan baik. Kita perlu:

  • Download Android Studio.
  • Download SDK tools terakhir dan platform menggunakan SDK Manager.

Catatan: Meskipun sebagian besar kelas latihan ini mengharapkan bahwa Anda menggunakan Android Studio, beberapa prosedur termasuk petunjuk alternatif untuk menggunakan SDK tool dari command line sebagai gantinya.

Bagian ini menggunakan format tutorial untuk membuat aplikasi Android kecil yang mengajarkan Anda beberapa konsep mendasar tentang perkembangan Android, jadi penting bahwa Anda mengikuti setiap langkah.


Membuat sebuah Android Project

Sebuah proyek Android berisi semua file yang terdiri dari kode sumber untuk aplikasi Android Anda.

Pelajaran ini menunjukkan bagaimana untuk membuat proyek baru baik menggunakan Android Studio atau menggunakan SDK tool dari command line.

Catatan: Anda harus sudah memiliki SDK Android diinstal, dan jika Anda menggunakan Android Studio, Anda juga harus memiliki Android Studio diinstal. Jika Anda tidak memiliki ini, ikuti panduan untuk Instalasi SDK Android sebelum Anda mulai pelajaran ini.


Buat Project dengan Android Studio

  • Di Android Studio, membuat sebuah project baru:
    • Jika tidak ada project yang dibuka, di Welcome screen, klik New Project.
    • Jika ada project yang dibuka, dari File menum pilih New Project.



   Figure 1. Configuring a new project in Android Studio.
  • Under Configure your new project, fill in the fields as shown in figure 1 and click Next.
   It will probably be easier to follow these lessons if you use the same values as shown.
    • Application Name is the app name that appears to users. For this project, use "My First App."
    • Company domain provides a qualifier that will be appended to the package name; Android Studio will remember this qualifier for each new project you create.
    • Package name is the fully qualified name for the project (following the same rules as those for naming packages in the Java programming language). Your package name must be unique across all packages installed on the Android system. You can Edit this value independently from the application name or the company domain.
    • Project location is the directory on your system that holds the project files.
  • Under Select the form factors your app will run on, check the box for Phone and Tablet.
  • For Minimum SDK, select API 8: Android 2.2 (Froyo).
   The Minimum Required SDK is the earliest version of Android that your app supports, indicated using the API level. To support as many devices as possible, you should set this to the lowest version available that allows your app to provide its core feature set. If any feature of your app is possible only on newer versions of Android and it's not critical to the app's core feature set, you can enable the feature only when running on the versions that support it (as discussed in Supporting Different Platform Versions).
  • Leave all of the other options (TV, Wear, and Glass) unchecked and click Next.

Referensi