Bearbeiten von „Android Training/Running Your Application“
Die Bearbeitung kann rückgängig gemacht werden. Bitte prüfe den Vergleich unten, um sicherzustellen, dass du dies tun möchtest, und veröffentliche dann unten deine Änderungen, um die Bearbeitung rückgängig zu machen.
Aktuelle Version | Dein Text | ||
Zeile 1: | Zeile 1: | ||
If you followed the [[Android Training/ Ein Android-Projekt erstellen|previous lesson]] to create an Android project, it includes a default set of "Hello World" source files that allow you to run the app right away. | |||
If you followed | |||
How you run your app depends on two things: whether you have a real Android-powered device and whether you’re using Eclipse. This lesson shows you how to install and run your app on a real device and on the Android emulator, and in both cases with either Eclipse or the command line tools. | |||
How you run your app depends on two things: whether you have a real device | |||
Before you run your app, you should be aware of a few directories and files in the Android project: | |||
< | ; <code>AndroidManifest.xml</code> : This manifest file describes the fundamental characteristics of the app and defines each of its components. You'll learn about various declarations in this file as you read more training classes. | ||
; <code>src/</code> : Directory for your app's main source files. By default, it includes an <code>[http://developer.android.com/reference/android/app/Activity.html Activity]</code> class that runs when your app is launched using the app icon. | |||
; <code>res/</code> : Contains several sub-directories for app resources. Here are just a few: | |||
:; <code>drawable-hdpi/</code> : Directory for drawable objects (such as bitmaps) that are designed for high-density (hdpi) screens. Other drawable directories contain assets designed for other screen densities. | |||
:; <code>layout/</code> : Directory for files that define your app's user interface. | |||
:; <code>values/</code> : Directory for other various XML files that contain a collection of resources, such as string and color definitions. | |||
When you build and run the default Android project, the default <code>[http://developer.android.com/reference/android/app/Activity.html Activity]</code> class in the <code>src/</code> directory starts and loads a layout file from the <code>layout/</code> directory, which includes a "Hello World" message. Not real exciting, but it's important that you understand how to build and run your app before adding real functionality to the app. | |||
== Run on a Real Device == | |||
Whether you’re using Eclipse or the command line, you need to: | |||
# Plug in your Android-powered device to your machine with a USB cable. If you’re developing on Windows, you might need to install the appropriate USB driver for your device. For help installing drivers, see the [http://developer.android.com/tools/extras/oem-usb.html OEM USB Drivers] document. | |||
# Ensure that '''USB debugging''' is enabled in the device Settings (open Settings and navitage to '''Applications > Development''' on most devices, or select '''Developer options''' on Android 4.0 and higher). | |||
To run the app from Eclipse, open one of your project's files and click '''Run''' from the toolbar. Eclipse installs the app on your connected device and starts it. | |||
Or to run your app from a command line: | |||
< | # Change directories to the root of your Android project and execute:<pre>ant debug</pre> | ||
Make sure the Android | # Make sure the Android SDK <code>platform-tools/</code> directory is included in your <code>PATH</code> environment variable, then execute:<pre>adb install bin/MyFirstApp-debug.apk</pre> | ||
# On your device, locate ''MyFirstActivity'' and open it. | |||
< | |||
On your device, | |||
To start adding stuff to the app, continue to the [[Android Training/ Eine einfache Benutzeroberfläche erstellen|next lesson]]. | |||
== Run on the Emulator == | == Run on the Emulator == | ||
Whether | Whether you’re using Eclipse or the command line, you need to first create an [http://developer.android.com/tools/devices/index.html Android Virtual Device] (AVD). An AVD is a device configuration for the Android emulator that allows you to model different device configurations. | ||
[[Datei:Avds-config.png|thumb| | [[Datei:Avds-config.png|thumb|The AVD Manager showing a few virtual devices.]] | ||
To create an AVD: | |||
# Launch the Android Virtual Device Manager: | # Launch the Android Virtual Device Manager: | ||
# | ## In Eclipse, select '''Window > AVD Manager''', or click the ''AVD Manager'' icon in the Eclipse toolbar. | ||
# | ## From the command line, change directories to <code><sdk>/tools/</code> and execute:<pre>./android avd</pre> | ||
# In the ''Android Virtual Device Device Manager'' panel, click '''New'''. | |||
# | # Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and a skin (HVGA is default). | ||
'' | # Click '''Create AVD'''. | ||
# Select the new AVD from the ''Android Virtual Device Manager'' and click '''Start'''. | |||
# | # After the emulator boots up, unlock the emulator screen. | ||
# Select the | |||
To run the app from Eclipse, open one of your project's files and click '''Run''' from the toolbar. Eclipse installs the app on your AVD and starts it. | |||
Or to run your app from the command line: | |||
# Change directories to the root of your Android project and execute:<pre>ant debug</pre> | |||
[[ | # Make sure the Android SDK <code>platform-tools/</code> directory is included in your <code>PATH</code> environment variable, then execute:<pre>adb install bin/MyFirstApp-debug.apk</pre> | ||
# On the emulator, locate ''MyFirstActivity'' and open it. | |||
To start adding stuff to the app, continue to the [[Android Training/ Eine einfache Benutzeroberfläche erstellen|next lesson]]. | |||
{{Android Training/ Vorlage:Attribution}} |