Difference between revisions of "Android Studio: Menjalankan Aplikasi"
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
Line 4: | Line 4: | ||
Jika Anda mengikuti pelajaran sebelumnya untuk membuat sebuah proyek Android, itu termasuk source code lengkap "Hello World" yang memungkinkan kita untuk menjalankan aplikasi segera. | Jika Anda mengikuti pelajaran sebelumnya untuk membuat sebuah proyek Android, itu termasuk source code lengkap "Hello World" yang memungkinkan kita untuk menjalankan aplikasi segera. | ||
− | + | Bagaimana Anda menjalankan aplikasi Anda tergantung pada dua hal: apakah Anda memiliki perangkat real yang menjalankan Android dan apakah Anda menggunakan Android Studio. Pelajaran ini menunjukkan kepada Anda bagaimana menginstal dan menjalankan aplikasi Anda pada perangkat real dan pada emulator Android, dan dalam kedua kasus dengan baik Android Studio atau perintah command line. | |
− | == | + | ==Menjalankan di Perangkat Real== |
− | + | Jika anda mempunya device yang menjalankan Android, berikut adalah cara menginstalasi dan menjalankan aplikasi anda. | |
− | |||
− | + | ||
+ | ===Set Up Perangkat=== | ||
+ | |||
+ | * Sambungkan perangkat Anda ke mesin pengembangan dengan kabel USB. | ||
Enable USB debugging on your device. | Enable USB debugging on your device. | ||
On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development. | On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development. | ||
Line 19: | Line 21: | ||
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. | 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. | ||
− | ==Run the app from Android Studio== | + | ===Run the app from Android Studio=== |
Select one of your project's files and click Run from the toolbar. | Select one of your project's files and click Run from the toolbar. | ||
Line 28: | Line 30: | ||
− | ==Run the app from a command line== | + | ===Run the app from a command line=== |
Open a command-line and navigate to the root of your project directory. Use Gradle to build your project in debug mode, invoke the assembleDebug build task using the Gradle wrapper script (gradlew assembleRelease). | Open a command-line and navigate to the root of your project directory. Use Gradle to build your project in debug mode, invoke the assembleDebug build task using the Gradle wrapper script (gradlew assembleRelease). | ||
Line 36: | Line 38: | ||
On Windows platforms, type this command: | On Windows platforms, type this command: | ||
− | > gradlew.bat assembleDebug | + | > gradlew.bat assembleDebug |
On Mac OS and Linux platforms, type these commands: | On Mac OS and Linux platforms, type these commands: | ||
− | $ chmod +x gradlew | + | $ chmod +x gradlew |
− | $ ./gradlew assembleDebug | + | $ ./gradlew assembleDebug |
After you build the project, the output APK for the app module is located in app/build/outputs/apk/ | After you build the project, the output APK for the app module is located in app/build/outputs/apk/ |
Revision as of 10:05, 4 May 2015
Sumber: https://developer.android.com/training/basics/firstapp/running-app.html
Jika Anda mengikuti pelajaran sebelumnya untuk membuat sebuah proyek Android, itu termasuk source code lengkap "Hello World" yang memungkinkan kita untuk menjalankan aplikasi segera.
Bagaimana Anda menjalankan aplikasi Anda tergantung pada dua hal: apakah Anda memiliki perangkat real yang menjalankan Android dan apakah Anda menggunakan Android Studio. Pelajaran ini menunjukkan kepada Anda bagaimana menginstal dan menjalankan aplikasi Anda pada perangkat real dan pada emulator Android, dan dalam kedua kasus dengan baik Android Studio atau perintah command line.
Menjalankan di Perangkat Real
Jika anda mempunya device yang menjalankan Android, berikut adalah cara menginstalasi dan menjalankan aplikasi anda.
Set Up Perangkat
- Sambungkan perangkat Anda ke mesin pengembangan dengan kabel USB.
Enable USB debugging on your device. On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development. On Android 4.0 and newer, it's in Settings > Developer options.
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.
Run the app from Android Studio
Select one of your project's files and click Run from the toolbar. In the Choose Device window that appears, select the Choose a running device radio button, select your device, and click OK .
Android Studio installs the app on your connected device and starts it.
Run the app from a command line
Open a command-line and navigate to the root of your project directory. Use Gradle to build your project in debug mode, invoke the assembleDebug build task using the Gradle wrapper script (gradlew assembleRelease).
This creates your debug .apk file inside the module build/ directory, named MyFirstApp-debug.apk.
On Windows platforms, type this command:
> gradlew.bat assembleDebug
On Mac OS and Linux platforms, type these commands:
$ chmod +x gradlew $ ./gradlew assembleDebug
After you build the project, the output APK for the app module is located in app/build/outputs/apk/
Note: The first command (chmod) adds the execution permission to the Gradle wrapper script and is only necessary the first time you build this project from the command line.
Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute:
adb install app/build/outputs/MyFirstApp-debug.apk
On your device, locate MyFirstApp and open it.
That's how you build and run your Android app on a device! To start developing, continue to the next lesson.