am c48e9bde: am 9911aa51: Merge "docs: studio training basics create and run project updates" into lmp-docs

automerge: 5f31276

* commit '5f3127620255167469fcba3d21334eb23217611d':
  docs: studio training basics create and run project updates
This commit is contained in:
Rich Slogar
2015-02-18 00:17:27 +00:00
committed by android-build-merger
2 changed files with 64 additions and 44 deletions

View File

@@ -100,10 +100,13 @@ lesson.</p>
Activities</a> for more information.</p> Activities</a> for more information.</p>
</div> </div>
</div> </div>
<li>Under <strong>Add an activity to your project</strong>, select <strong>Blank Activity</strong> <li>Under <strong>Add an activity to &lt;<em>template</em>&gt;</strong>, select <strong>Blank
and click <strong>Next</strong>.</li> Activity</strong> and click <strong>Next</strong>.</li>
<li>Under <strong>Describe the new activity for your project</strong>, leave the fields as they <li>Under <strong>Choose options for your new file</strong>, change the
are and click <strong>Finish</strong>.</li> <strong>Activity Name</strong> to <em>MyActivity</em>. The <strong>Layout Name</strong> changes
to <em>activity_my</em>, and the <strong>Title</strong> to <em>MyActivity</em>. The
<strong>Menu Resource Name</strong> is <em>menu_my</em>.
<li>Click the <strong>Finish</strong> button to create the project.</li>
</ol> </ol>
<p>Your Android project is now a basic "Hello World" app that contains some default files. Take a <p>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:</p>
select the file you see the class definition for the activity you created. When you build and 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 run the app, the {@link android.app.Activity} class starts the activity and loads the layout file
that says "Hello World!"</dd> that says "Hello World!"</dd>
<dt><code>app/src/res/AndroidManifest.xml</code></dt> <dt><code>app/src/main/AndroidManifest.xml</code></dt>
<dd>The <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest file</a> describes <dd>The <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest file</a> describes
the fundamental characteristics of the app and defines each of its components. You'll revisit 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.</dd> this file as you follow these lessons and add more components to your app.</dd>
@@ -156,13 +159,16 @@ moment to review the most important of these:</p>
<p>Note also the <code>/res</code> subdirectories that contain the <p>Note also the <code>/res</code> subdirectories that contain the
<a href="{@docRoot}guide/topics/resources/overview.html">resources</a> for your application:</p> <a href="{@docRoot}guide/topics/resources/overview.html">resources</a> for your application:</p>
<dl> <dl>
<dt><code>drawable-hdpi/</code></dt> <dt><code>drawable<em>&lt;density&gt;</em>/</code></dt>
<dd>Directory for drawable objects (such as bitmaps) that are designed for high-density <dd>Directories for drawable objects (such as bitmaps) that are designed for various densities,
(hdpi) screens. Other drawable directories contain assets designed for other screen 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.</dd> Here you'll find the ic_launcher.png that appears when you run the default app.</dd>
<dt><code>layout/</code></dt> <dt><code>layout/</code></dt>
<dd>Directory for files that define your app's user interface like activity_my.xml, <dd>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.</dd> discussed above, which describes a basic layout for the MyActivity class.</dd>
<dt><code>menu/</code></dt>
<dd>Directory for files that define your app's menu items.</dd>
<dt><code>values/</code></dt> <dt><code>values/</code></dt>
<dd>Directory for other XML files that contain a collection of resources, such as <dd>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 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:</p>
using the SDK tools from a command line:</p> using the SDK tools from a command line:</p>
<ol> <ol>
<li>Change directories into the Android SDK’s <code>tools/</code> path.</li> <li>Change directories into the Android SDK’s <code>sdk/</code> path.</li>
<li>Execute: <li>Execute:
<pre class="no-pretty-print">android list targets</pre> <pre class="no-pretty-print">tools/android list targets</pre>
<p>This prints a list of the available Android platforms that you’ve downloaded for your SDK. Find <p>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 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 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 <a href="running-app.html">next lesson</a>.</p>

View File

@@ -83,14 +83,37 @@ from the toolbar.</li>
<h3>Run the app from a command line</h3> <h3>Run the app from a command line</h3>
<ol> <p>Open a command-line and navigate to the root of your project directory.
<li>Change directories to the root of your Android project and execute: Use Gradle to build your project in debug mode, invoke the <code>assembleDebug</code> build task
<pre class="no-pretty-print">ant debug</pre></li> using the Gradle wrapper script (<code>gradlew assembleRelease</code>).
<li>Make sure the Android SDK <code>platform-tools/</code> directory is included in your
<code>PATH</code> environment variable, then execute: <p>This creates your debug <code>.apk</code> file inside the module <code>build/</code>
<pre class="no-pretty-print">adb install bin/MyFirstApp-debug.apk</pre></li> directory, named <code>MyFirstApp-debug.apk</code>. </p>
<li>On your device, locate <em>MyFirstApp</em> and open it.</li>
</ol> <p>On Windows platforms, type this command:</p>
<pre>
> gradlew.bat assembleDebug
</pre>
<p>On Mac OS and Linux platforms, type these commands:</p>
<pre>
$ chmod +x gradlew
$ ./gradlew assembleDebug
</pre>
<p>After you build the project, the output APK for the app module is located in
<code>app/build/outputs/apk/</code>
<p class="note"><strong>Note:</strong> The first command (<code>chmod</code>) adds the execution
permission to the Gradle wrapper script and is only necessary the first time you build this
project from the command line.</p>
<p>Make sure the Android SDK <code>platform-tools/</code> directory is included in your
<code>PATH</code> environment variable, then execute:
<pre class="no-pretty-print">adb install app/build/outputs/MyFirstApp-debug.apk</pre><p>
<p>On your device, locate <em>MyFirstApp</em> and open it.</p>
<p>That's how you build and run your Android app on a device! <p>That's how you build and run your Android app on a device!
To start developing, continue to the <a href="building-ui.html">next To start developing, continue to the <a href="building-ui.html">next
@@ -113,11 +136,11 @@ device.</p>
<li>In Android Studio, select <strong>Tools &gt; Android &gt; AVD Manager</strong>, or click <li>In Android Studio, select <strong>Tools &gt; Android &gt; AVD Manager</strong>, or click
the AVD Manager icon <img src="{@docRoot}images/tools/avd-manager-studio.png" style="vertical-align:bottom;margin:0;height:19px"> in the toolbar.</li> the AVD Manager icon <img src="{@docRoot}images/tools/avd-manager-studio.png" style="vertical-align:bottom;margin:0;height:19px"> in the toolbar.</li>
<li>Or, from the command line, change directories to <li>Or, from the command line, change directories to
<code>&lt;sdk>/tools/</code> and execute: <code>sdk/</code> and execute:
<pre class="no-pretty-print">android avd</pre> <pre class="no-pretty-print">tools/android avd</pre>
<p class="note"><strong>Note:</strong> The AVD Manager that appears <p class="note"><strong>Note:</strong> The AVD Manager that appears
when launched from the command line is different from the version in when launched from the command line is different from the version in
Android Studio, so the following instructions may not apply.</p> Android Studio, so the following instructions may not all apply.</p>
</li> </li>
</ul> </ul>
@@ -127,7 +150,6 @@ device.</p>
</li> </li>
<li>On the AVD Manager main screen (figure 1), click <strong>Create Virtual Device</strong>.</li> <li>On the AVD Manager main screen (figure 1), click <strong>Create Virtual Device</strong>.</li>
<li>In the Select Hardware window, select a device configuration, such as Nexus 6, <li>In the Select Hardware window, select a device configuration, such as Nexus 6,
then click <strong>Next</strong>. then click <strong>Next</strong>.
</li> </li>
@@ -143,40 +165,33 @@ device.</p>
<h3>Run the app from Android Studio</h3> <h3>Run the app from Android Studio</h3>
<ol> <ol>
<li>In <strong>Android Studio</strong>, select your project and click <strong>Run</strong> <li>In <strong>Android Studio</strong>, select your project and click <strong>Run</strong>
<img src="{@docRoot}images/tools/as-run.png" style="vertical-align:baseline;margin:0; max-height:1em" /> <img src="{@docRoot}images/tools/as-run.png" style="vertical-align:baseline;margin:0; max-height:1em" /> from the toolbar.</li>
from the toolbar.</li>
<li>In the <strong>Choose Device</strong> window, click the <strong>Launch emulator</strong> radio <li>In the <strong>Choose Device</strong> window, click the <strong>Launch emulator</strong> radio
button.</li> button.</li>
<li>From the <strong>Android virtual device</strong> pull-down menu, select the emulator <li>From the <strong>Android virtual device</strong> pull-down menu, select the emulator
you created, and click <strong>OK</strong>.</li> you created, and click <strong>OK</strong>.</li>
</ol> </ol>
<p>It can take a few minutes for the emulator to load itself. You may have to unlock the screen. <p>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.</p> When you do, <em>My First App</em> appears on the emulator screen.</p>
<h3>Run your app from the command line</h3> <h3>Run your app from the command line</h3>
<ol>
<ol> <li>Build the project from the command line. The output APK for the app module is located in
<li>Change directories to the root of your Android project and execute: <code>app/build/outputs/apk/</code>.</li>
<pre class="no-pretty-print">ant debug</pre></li>
<li>Make sure the Android SDK <code>platform-tools/</code> directory is included in your <li>Make sure the Android SDK <code>platform-tools/</code> directory is included in your
<code>PATH</code> environment variable, then execute: <code>PATH</code> environment variable.</li>
<pre class="no-pretty-print">adb install bin/MyFirstApp-debug.apk</pre></li> <li>Execute this command:
<p>
<pre class="no-pretty-print">adb install app/build/outputs/MyFirstApp-debug.apk</pre>
</p>
</li>
<li>On the emulator, locate <em>MyFirstApp</em> and open it.</li> <li>On the emulator, locate <em>MyFirstApp</em> and open it.</li>
</ol> </ol>
<p>That's how you build and run your Android app on the emulator! <p>That's how you build and run your Android app on the emulator!
To start developing, continue to the <a href="building-ui.html">next To start developing, continue to the <a href="building-ui.html">next
lesson</a>.</p> lesson</a>.</p>