| page.title=Creating an Android Project |
| |
| page.tags=project setup |
| helpoutsWidget=true |
| |
| trainingnavtop=true |
| next.title=Running Your App |
| next.link=running-app.html |
| |
| @jd:body |
| |
| |
| <!-- This is the training bar --> |
| <div id="tb-wrapper"> |
| <div id="tb"> |
| |
| <h2>You should also read</h2> |
| |
| <ul> |
| <li><a href="{@docRoot}studio/projects/index.html">Projects Overview</a></li> |
| </ul> |
| |
| |
| </div> |
| </div> |
| |
| <p>This lesson shows you how to create a new Android project with |
| <a href="{@docRoot}studio/index.html">Android Studio</a> and describes some |
| of the files in the project.</p> |
| |
| <ol> |
| <li>In Android Studio, create a new project: |
| <ul> |
| <li>If you don't have a project opened, in the <strong>Welcome to Android Studio</strong> window, click <strong> |
| Start a new Android Studio project</strong>.</li> |
| <li>If you have a project opened, select <strong>File > New Project</strong>.</li> |
| </ul> |
| </li> |
| <li>In the <b>New Project</b> screen, enter the following values:</p> |
| <ul> |
| <li><strong>Application Name</strong>: "My First App" </li> |
| <li><strong>Company Domain</strong>: "example.com"</li> |
| </ul> |
| <p>Android Studio fills in the package name and project location for you, |
| but you can edit these if you'd like. |
| </li> |
| <li>Click <b>Next</b>.</li> |
| <li>In the <b>Target Android Devices</b> screen, keep the default values and |
| click <b>Next</b>. |
| <p>The <b>Minimum Required SDK</b> is the earliest version of Android that your app supports, |
| which is indicated by the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels"> |
| API level</a>. 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 core |
| feature set, enable that feature only when running on the versions that support it (see |
| <a href="{@docRoot}training/basics/supporting-devices/platforms.html"> |
| Supporting Different Platform Versions</a>).</p> |
| </li> |
| |
| <li>In the <strong>Add an Activity to Mobile</strong> screen, select <strong>Empty |
| Activity</strong> and click <strong>Next</strong>. |
| </li> |
| |
| <li>In the <strong>Customize the Activity</strong> screen, keep the default values |
| and click <strong>Finish</strong>. |
| </ol> |
| |
| <p>After some processing, Android Studio opens and displays a "Hello World" app |
| with default files. You will add functionality to some of |
| these files in the following lessons.</p> |
| |
| <p>Now take a moment to review the most important files. First, be sure that |
| the <b>Project</b> window is open (select <b>View > Tool Windows > Project</b>) |
| and the <b>Android</b> view is selected from the drop-down list at the top. |
| You can then see the following files:</p> |
| |
| <dl> |
| <dt><b>app > java > com.example.myfirstapp > MainActivity.java</b></dt> |
| <dd>This file appears in Android Studio after the New Project wizard finishes. |
| It contains the class definition for the activity you created earlier. When you build |
| and run the app, the {@link android.app.Activity} starts and loads the |
| layout file that says "Hello World!"</dd> |
| |
| <dt><b>app > res > layout > activity_main.xml</b></dt> |
| <dd>This XML file defines the layout of the activity. It contains a {@code TextView} |
| element with the text "Hello world!".</dd> |
| |
| <dt><b>app > manifests > AndroidManifest.xml</b></dt> |
| <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 |
| this file as you follow these lessons and add more components to your app.</dd> |
| |
| <dt><b>Gradle Scripts > build.gradle</b></dt> |
| <dd>Android Studio uses Gradle to compile and build your app. There is a <code>build.gradle</code> |
| file for each module of your project, as well as a <code>build.gradle</code> file for the entire |
| project. Usually, you're only interested in the <code>build.gradle</code> file for the module. |
| in this case the <code>app</code> or application module. For more information about this file, |
| see <a href="{@docRoot}studio/build/index.html">Building Your Project with Gradle</a>.</dd> |
| </dl> |
| |
| <p> |
| To run the app, continue to the <a href="running-app.html">next lesson</a>. |
| </p> |