-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsetup.html
More file actions
50 lines (50 loc) · 17.8 KB
/
setup.html
File metadata and controls
50 lines (50 loc) · 17.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>setup · codebar android tutorials</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Setting up Android Studio"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="setup · codebar android tutorials"/><meta property="og:type" content="website"/><meta property="og:url" content="https://codebar.github.io/android-tutorials/"/><meta property="og:description" content="# Setting up Android Studio"/><meta property="og:image" content="https://codebar.github.io/android-tutorials/img/undraw_online.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://codebar.github.io/android-tutorials/img/undraw_tweetstorm.svg"/><link rel="shortcut icon" href="/android-tutorials/img/favicon.ico"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><link rel="alternate" type="application/atom+xml" href="https://codebar.github.io/android-tutorials/blog/atom.xml" title="codebar android tutorials Blog ATOM Feed"/><link rel="alternate" type="application/rss+xml" href="https://codebar.github.io/android-tutorials/blog/feed.xml" title="codebar android tutorials Blog RSS Feed"/><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/android-tutorials/js/scrollSpy.js"></script><link rel="stylesheet" href="/android-tutorials/css/main.css"/><script src="/android-tutorials/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/android-tutorials/"><img class="logo" src="/android-tutorials/img/codebar-full-white-logo.png" alt="codebar android tutorials"/><h2 class="headerTitleWithLogo">codebar android tutorials</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavItemActive"><a href="/android-tutorials/docs/setup" target="_self">Getting Setup</a></li><li class=""><a href="/android-tutorials/docs/cookie-clicker-java" target="_self">Kotlin Tutorials</a></li><li class=""><a href="/android-tutorials/blog/" target="_self">Blog</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container mainContainer"><div class="wrapper"><div class="post"><header class="postHeader"><h1 class="postHeaderTitle">setup</h1></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="setting-up-android-studio"></a><a href="#setting-up-android-studio" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Setting up Android Studio</h1>
<p><em>This tutorial will guide you through the process of setting up Android Studio, a phone or emulator, and then making sure it is all working by running an app on it. If you are attending an Android workshop at Codebar, we encourage you to work through this tutorial before you come along. If you get stuck, don't worry, just stop where you are, and a coach can help you on the day. It is very useful, however, if you can at least download Android Studio before you arrive as it is a big download and the internet can become a problem if too many people try and download it at once.</em></p>
<h2><a class="anchor" aria-hidden="true" id="1-setting-up-android-studio"></a><a href="#1-setting-up-android-studio" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>1. Setting up Android Studio</h2>
<p>Android Studio is the IDE you will use for creating Android applications. IDE stands for <strong>I</strong>ntegrated <strong>D</strong>evelopment <strong>E</strong>nvironment, which means it has all the tools you need for development built right into one application. You will use Android Studio in place of your normal text editor (such as Notepad, Sublime Text, or Atom) and use it to build and run your apps on your Android phone.</p>
<p>You first need to <a href="https://developer.android.com/studio/index.html">download the installer from this page</a>. You can then follow the instructions to install Android Studio and the Android SDK. There is a video on <a href="https://developer.android.com/studio/install.html">this page</a> which will show you the installation process from start to finish.</p>
<p>Once you have finished the installation, you will be greeted with this lovely welcome screen!</p>
<p><img src="/android-tutorials/docs/assets/setup/android-studio-welcome.png" alt="Android Studio Welcome Screen"></p>
<h2><a class="anchor" aria-hidden="true" id="2-creating-your-first-android-project"></a><a href="#2-creating-your-first-android-project" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>2. Creating your first Android project</h2>
<p>We are now going to create an Android project within Android Studio. On the welcome screen, press <em>Start a new Android Studio project</em>. This will open a window which will ask you for a few things about your new application. Give it a name such as <em>My First App</em> and then fill in the company domain box. If you have your own website (such as <code>adalovelace.co.uk</code>) you can use that. If not, use something like <code>yourname.codebar.com</code>. It doesn't matter if this is a real website, this is just a way for Android to give your app a unique identifier.</p>
<blockquote>
<p>For example, if you have an app called <em>My First App</em> and your domain name is <code>adalovelace.co.uk</code> then Android will give it an identifier <code>uk.co.adalovelace.myfirstapp</code>. This is called the <em>package name</em>. As no two apps can have the same package name, this reverse domain system avoids clashes.</p>
</blockquote>
<p>You should also choose a location for the project which is where the files will be stored. When you're done, press the next button.</p>
<p><img src="/android-tutorials/docs/assets/setup/first-project-1-name.png" alt="Setting the Android project name"></p>
<p>On the next screen, you are asked which Android phones you want to support. You can leave that at the default (which in my case is Android 4.4, KitKat). If you are interested, you can click on the <em>Help me choose</em> link to see what percentage of users run each version of Android. Make sure only <em>Phone & tablets</em> is checked and press <em>Next</em>.</p>
<blockquote>
<p>Did you notice that different versions of Android have different names? The third version of Android was called <em>Cupcake</em>. The fourth version was called <em>Doughnut</em>. Every version since has carried on with a "sweet treat" starting with the next letter of the alphabet. You can see a list of all the names <a href="https://en.wikipedia.org/wiki/Android_version_history">here</a>.</p>
</blockquote>
<p><img src="/android-tutorials/docs/assets/setup/first-project-2-version.png" alt="Choosing which version of Android to support"></p>
<p>Once the downloads have completed, press <em>Next</em> again and then choose the type of <em>Activity</em> you want your app to use. An Activity is how Android refers to a screen within apps. Your app can have multiple activities, and you can move between them to see different parts of the app. For now, we want to create an app with a <em>Empty activity</em>. Make sure that is selected and then press <em>Next</em>.</p>
<p><img src="/android-tutorials/docs/assets/setup/first-project-3-activity.png" alt="Selected the type of activity for our Android app"></p>
<p>Leave the next screen with all the default options (these are the names of the files Android Studio will create for you) and press <em>Finish</em>. In a few seconds, the main Android Studio window will open. For now, it will look blank, but we will be able to build and run our app from here in a minute.</p>
<p><img src="/android-tutorials/docs/assets/setup/first-project-4-complete.png" alt="The Android Studio IDE when the project is created"></p>
<p>First, we need to set up a phone for it to run on.</p>
<h2><a class="anchor" aria-hidden="true" id="3-setting-up-a-device-or-the-emulator"></a><a href="#3-setting-up-a-device-or-the-emulator" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>3. Setting up a device or the emulator</h2>
<p>Android applications can only be run on an Android phone, but don't worry if you don't have one, you can also run an <em>emulator</em> on your computer. An emulator is a program which pretends to be something else. In this case, you can run one through Android Studio which will pretend to be an Android phone. Emulators can be slow, however, so if you have an Android phone follow the steps below to set it up. If you don't, follow the steps to setup the emulator.</p>
<h3><a class="anchor" aria-hidden="true" id="31-setting-up-your-android-phone"></a><a href="#31-setting-up-your-android-phone" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>3.1 Setting up your Android phone</h3>
<p>Grab you Android phone and plug it into your computer with a USB cable. If you are using a Windows computer, you might need to install some drivers. You can do that <a href="https://developer.android.com/studio/run/oem-usb.html">by following the instructions on this page</a>.</p>
<p>Now, on your Android phone you need to make sure <em>USB debugging</em> is turned on. Go to the phone settings and then scroll down to <em>About phone</em>. On this screen, continue to tap on the <em>Build number</em> section until it shows a message saying <em>You are now a developer</em> (if only it were always that easy!).</p>
<p><img src="/android-tutorials/docs/assets/setup/android-device-developer-mode.gif" alt="Android Device Developer Mode"></p>
<p>Now you are in developer mode, press back and you should see a new <em>Developer options</em> menu. Tap into there and make sure the switch at the top of the screen is turned on. Then scroll down and make sure <em>USB Debugging</em> is also turned on.</p>
<h3><a class="anchor" aria-hidden="true" id="32-setting-up-the-android-emulator"></a><a href="#32-setting-up-the-android-emulator" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>3.2 Setting up the Android emulator</h3>
<p>If you don't have an Android phone, you can also set up an emulator to run on your computer.</p>
<p>First, in Android Studio with your project open, Launch the Android Virtual Device Manager by selecting <em>Tools</em> > <em>Android</em> > <em>AVD Manager</em>, or by clicking the AVD Manager icon <img src="https://developer.android.com/images/tools/avd-manager-studio.png" style="height: 1.5em; vertical-align: middle" alt="" /> in the toolbar. On the screen which opens, press the <em>Create Virtual Device</em> button.</p>
<p>On this screen, you need to pick which type of device you want to create. Feel free to browse around, but we are going to choose the <em>Phone</em> category and then the <em>Pixel</em> device. Press <em>Next</em>.</p>
<p><img src="/android-tutorials/docs/assets/setup/emulator-1-type.png" alt="Selecting the emulator device type"></p>
<p>We are now asked to choose which version of Android we want to use. Make sure the recommended tab is selected and then select any of the options by pressing the <em>Download</em> link. You might be asked to accept some terms to continue. Once the download is complete you can press <em>Finish</em> to go back to the screen and select that version of Android and press <em>Next</em> again.</p>
<p><img src="/android-tutorials/docs/assets/setup/emulator-2-version.png" alt="Selecting the emulator device type"></p>
<p>On the next screen leave everything as it is and press <em>Finish</em>. This will finish creating the emulator and add it to the list with a name like <em>Pixel API 23</em> (your name might be slightly different if you chose a different Android version).</p>
<p><img src="/android-tutorials/docs/assets/setup/emulator-3-list.png" alt="The list of emulators"></p>
<p>You can now start the emulator by pressing the play button <img src="https://developer.android.com/images/tools/as-avd-start.png" style="height: 1.3em" alt="" /> next to your newly created emulator. It will take a few minutes to start but will eventually show an Android phone in a window on your computer.</p>
<p><img src="/android-tutorials/docs/assets/setup/emulator-4-complete.png" alt="The android emulator running"></p>
<p>Having troubles setting up the emulator? Check out this <a href="https://developer.android.com/studio/run/emulator-troubleshooting">troubleshooting guide</a>.</p>
<h2><a class="anchor" aria-hidden="true" id="4-running-the-app-on-your-phone-emulator"></a><a href="#4-running-the-app-on-your-phone-emulator" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>4. Running the app on your phone/emulator</h2>
<p>We are now going to run your first application to make sure everything is working. All you need to do is press the run button <img src="https://developer.android.com/studio/images/buttons/toolbar-run.png" style="height: 1.3em" alt="" /> in the toolbar of your Android Studio project window and then make sure your phone or emulator is selected in the window which pops up.</p>
<p><img src="/android-tutorials/docs/assets/setup/run-1-chooser.png" alt="Choosing the Android device to run the app on"></p>
<p>After a short time, the app will be built and run on your phone or emulator. It should look like this:</p>
<p><img src="/android-tutorials/docs/assets/setup/run-2-running.png" alt="Our app running on the Android emulator"></p>
<p>That's it! You're all set up and ready for the [first tutorial]({{ site.baseurl }}/worksheets/1-introduction/)! You can also view some more links over on the [resources page]({{ site.baseurl }}/worksheets/0-resources.html).</p>
</span></div></article></div><div class="docs-prevnext"></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#1-setting-up-android-studio">1. Setting up Android Studio</a></li><li><a href="#2-creating-your-first-android-project">2. Creating your first Android project</a></li><li><a href="#3-setting-up-a-device-or-the-emulator">3. Setting up a device or the emulator</a><ul class="toc-headings"><li><a href="#31-setting-up-your-android-phone">3.1 Setting up your Android phone</a></li><li><a href="#32-setting-up-the-android-emulator">3.2 Setting up the Android emulator</a></li></ul></li><li><a href="#4-running-the-app-on-your-phone-emulator">4. Running the app on your phone/emulator</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/android-tutorials/docs/en/attributions.html">Attributions</a></section><a href="https://codebar.io/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/android-tutorials/img/codebar-full-white-logo.png" alt="codebar"/></a></footer></div></body></html>