When you first create a project, the project assets are in the Project window. If you don't see the Project window, click on the Project tab on the left or move the cursor down to the lower left corner and choose Project. There are a few different views in the Project window. The default is called Android. It organizes the project assets by type. The AndroidManifest file, an XML file, is visible here under manifests. All of the Java classes are available under the "java" directory, and resources are available under "res". But this structure doesn't reflect the actual physical organization on disk. To see that, change to the scope Project. And now you'll see what's actually on your hard disk. The top-level project will show you the actual physical location and you can open that and see what else is in the project. The app tree has all the actual application assets. Under src for source, you'll find main, and under that java.
- [Voiceover] When you first create a project in Android Studio, the project's assets are shown in the project window on the left. If you don't see the project window, you can click on the Project tab, and that opens and closes that window, or you can move the cursor down to the lower-left corner and when the menu pops up, you can choose project from there. The project window by default shows a view named Android, and it only shows certain files and folders that are relevant when you're doing your day-to-day programming, but it doesn't show the actual underlying file structure on disk.
To see that, change the view to Project, and now you'll see the actual files and folders. If you go to the top item, which represents the project itself, you can click this spinner icon to open it up. You can also right click on that item and then choose Reveal in Finder, or Reveal in Explorer, to look at that folder in your file manager. Here are some of the files that are in the project folder. There's a file named build.gradle, which configures the Gradle build tool.
You'll see a class path indicating the current version of Gradle that you're using. I'm using Android Studio 2 Beta 6, and so I'm using a matching Gradle tool. If you're using a later version of Android Studio, the value you see here will be different. There's also a file named gradle.properties, which is used to configure the Gradle build tool, and local.properties which has some configuration values for the project itself. Notice that there's a value here called sdk.dir which points to your copy of the Android SDK.
This value will be different from one computer to another, and when I deliver exercise files for Android projects, I strip this file out. It will be regenerated when the project is opened on any other computer to point to that developer's copy of the Android SDK. The IML file contains project configuration values for Android Studio and the underlying IntelliJ IDEA, and there's a settings.gradle file too, which indicates which modules this project includes.
Some of these other subfolders of the project can be ignored. The .gradle and .idea folders contain configuration information for the development environment, and not for your project. The build folder contains generated files that are only used during the packaging process. Your project lives here, under the folder, app. This is a module directory. Each project in Android Studio can have multiple modules, and each module is represented by one directory.
I'll go to the menu and choose File, Project Structure, and under Modules, I see that directory listing. When you select a module and then you make changes in these configuration tabs, you're actually making changes in a couple of configuration files that are a part of the module. If you make changes up here, such as for the SDK location, then you're making changes in files that are a part of the project, and not the module. Within the module directory, once again there's a build directory, and again it contains generated files.
You never want to change anything in the build directory. Any changes you make manually will be lost the next time you remake the application. There is an empty libs folder by default, and this is where you would put your jar files, that is, archive files that contain pre-compiled Java classes. There's a file named gitignore, and this is used to indicate which files or folders should not be checked in to the version control system, git. Once again, there's an IML file, for IntelliJ IDEA configuration, and another build.gradle file.
This is the one for your project, and it contains configurations for the SDK versions, the application ID, which tools you're using for your compilation, and dependencies that I'll talk about in another video. There's also a configuration file for ProGuard, the tool that's used to minimize the size of your project package before you distribute it to your users. ProGuard can also be used to obfuscate Java code so that your object is harder to decompile.
Within the source subdirectory, there's another folder named main, and this is where the guts of your application live. This is where you'll find the Android manifest file, where you register your activities, services, and other app components. The resources folder, where you put your drawable files, your XML layout files, your launcher icons, and XML files for various values. Finally, your Java directory, and this is where you put your actual Java code.
You'll see that there's a Java package represented here. There's a complete package directory structure on disk, that is, there's a subdirectory named com, and it has a subdirectory named example, and so on, but those are flattened by default in this visual presentation to make it easier to find your Java classes. There are two other subdirectories of the source directory. Test contains an example unit test for Java testing, and Android test contains a sample for doing Android-specific testing.
If you want to do test-driven development, that is, write unit tests as you develop your app, these directories are where you'll place your testing classes. That's a look at how to find your way through the Android Studio project. My recommendation is to keep the project view set to Android, so that you're only seeing the files and folders you use on a daily basis, and then go to the project view when you need to get to other files and folders that are a part of the project.
- Installing Android Studio on Mac and Windows
- Creating Android Studio projects
- Setting up the development environment, including HAXM and the new Android emulator
- Importing existing code into Android Studio projects
- Exploring the interface, including the editor and project windows
- Managing project builds and dependencies
- Creating new Java classes
- Refactoring code
- Using templates
- Using breakpoints and watch expressions
- Updating apps with Instant Run
- Using Git for version control
Skill Level Beginner
Q: This course was updated on 04/27/2017. What changed?
A: New videos were added that highlight the new features introduced in Android Studio 2.3. In addition, the following topic was updated: update apps with Instant Run.