From 453467ac9c32a25ea31a8aacea7f5168b703e6db Mon Sep 17 00:00:00 2001 From: Rich Slogar Date: Mon, 15 Dec 2014 12:33:03 -0800 Subject: docs: studio training basics create and run project updates b/18742781 Change-Id: I80a207e24330c1b073934d671b3b9c94b0fb28e0 --- .../training/basics/firstapp/creating-project.jd | 27 +++++--- docs/html/training/basics/firstapp/running-app.jd | 81 +++++++++++++--------- 2 files changed, 64 insertions(+), 44 deletions(-) (limited to 'docs/html/training') diff --git a/docs/html/training/basics/firstapp/creating-project.jd b/docs/html/training/basics/firstapp/creating-project.jd index bb4d2e1..4bd92ee 100644 --- a/docs/html/training/basics/firstapp/creating-project.jd +++ b/docs/html/training/basics/firstapp/creating-project.jd @@ -100,10 +100,13 @@ lesson.

Activities for more information.

-
  • Under Add an activity to your project, select Blank Activity - and click Next.
  • -
  • Under Describe the new activity for your project, leave the fields as they - are and click Finish.
  • +
  • Under Add an activity to <template>, select Blank + Activity and click Next.
  • +
  • Under Choose options for your new file, change the + Activity Name to MyActivity. The Layout Name changes + to activity_my, and the Title to MyActivity. The + Menu Resource Name is menu_my. +
  • Click the Finish button to create the project.
  • Your Android project is now a basic "Hello World" app that contains some default files. Take a @@ -120,7 +123,7 @@ moment to review the most important of these:

    select the file you see the class definition for the activity you created. When you build and run the app, the {@link android.app.Activity} class starts the activity and loads the layout file that says "Hello World!" -
    app/src/res/AndroidManifest.xml
    +
    app/src/main/AndroidManifest.xml
    The manifest file describes the fundamental characteristics of the app and defines each of its components. You'll revisit this file as you follow these lessons and add more components to your app.
    @@ -156,13 +159,16 @@ moment to review the most important of these:

    Note also the /res subdirectories that contain the resources for your application:

    -
    drawable-hdpi/
    -
    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. +
    drawable<density>/
    +
    Directories for drawable objects (such as bitmaps) that are designed for various densities, + such as medium-density (mdpi) and high-density (hdpi) screens. Other drawable directories + contain assets designed for other screen densities. Here you'll find the ic_launcher.png that appears when you run the default app.
    layout/
    Directory for files that define your app's user interface like activity_my.xml, discussed above, which describes a basic layout for the MyActivity class.
    +
    menu/
    +
    Directory for files that define your app's menu items.
    values/
    Directory for other XML files that contain a collection of resources, such as string and color definitions. The strings.xml file defines the "Hello world!" string that @@ -177,9 +183,9 @@ moment to review the most important of these:

    using the SDK tools from a command line:

      -
    1. Change directories into the Android SDK’s tools/ path.
    2. +
    3. Change directories into the Android SDK’s sdk/ path.
    4. Execute: -
      android list targets
      +
      tools/android list targets

      This prints a list of the available Android platforms that you’ve downloaded for your SDK. Find the platform against which you want to compile your app. Make a note of the target ID. We recommend that you select the highest version possible. You can still build your app to @@ -209,4 +215,3 @@ To run the app, continue to the next lesson.

      - diff --git a/docs/html/training/basics/firstapp/running-app.jd b/docs/html/training/basics/firstapp/running-app.jd index 912efb7..6e4605f 100644 --- a/docs/html/training/basics/firstapp/running-app.jd +++ b/docs/html/training/basics/firstapp/running-app.jd @@ -83,14 +83,37 @@ from the toolbar.
    5. Run the app from a command line

      -
        -
      1. Change directories to the root of your Android project and execute: -
        ant debug
      2. -
      3. Make sure the Android SDK platform-tools/ directory is included in your -PATH environment variable, then execute: -
        adb install bin/MyFirstApp-debug.apk
      4. -
      5. On your device, locate MyFirstApp and open it.
      6. -
      +

      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 @@ -113,11 +136,11 @@ device.

    6. In Android Studio, select Tools > Android > AVD Manager, or click the AVD Manager icon in the toolbar.
    7. Or, from the command line, change directories to - <sdk>/tools/ and execute: -
      android avd
      + sdk/ and execute: +
      tools/android avd

      Note: The AVD Manager that appears when launched from the command line is different from the version in - Android Studio, so the following instructions may not apply.

      + Android Studio, so the following instructions may not all apply.

    8. @@ -127,7 +150,6 @@ device.

    9. On the AVD Manager main screen (figure 1), click Create Virtual Device.
    10. -
    11. In the Select Hardware window, select a device configuration, such as Nexus 6, then click Next.
    12. @@ -143,40 +165,33 @@ device.

      Run the app from Android Studio

      1. In Android Studio, select your project and click Run - - from the toolbar.
      2. + from the toolbar.
      3. In the Choose Device window, click the Launch emulator radio button.
      4. From the Android virtual device pull-down menu, select the emulator you created, and click OK.

      It can take a few minutes for the emulator to load itself. You may have to unlock the screen. - When you do, My First App appears on the emulator screen.

      +When you do, My First App appears on the emulator screen.

      Run your app from the command line

      - -
        -
      1. Change directories to the root of your Android project and execute: -
        ant debug
      2. +
          +
        1. Build the project from the command line. The output APK for the app module is located in + app/build/outputs/apk/.
        2. Make sure the Android SDK platform-tools/ directory is included in your - PATH environment variable, then execute: -
          adb install bin/MyFirstApp-debug.apk
        3. + PATH environment variable. +
        4. Execute this command: +

          +

          adb install app/build/outputs/MyFirstApp-debug.apk
          +

          +
        5. On the emulator, locate MyFirstApp and open it.
        6. -
        +
      -

      That's how you build and run your Android app on the emulator! +

      That's how you build and run your Android app on the emulator! To start developing, continue to the next -lesson.

      - - - - - - - - - + lesson.

      -- cgit v1.1