Below is a list of optional processes that you can do with Android Studio.
There are several scopes in the Project window. The top two views that you will be using is the Android and Project view.
The Android is the default view which organizes assets by type to shows the most important folders and files but does not reflect the actual structure on the computer. In this view, files are hidden that are are used to manager Android Studio so you can focus on files that are modified the most (manifest, java, resources, and Gradle Scripts).
app folder contains:
Gradle Scripts contains:
It is best practice to used the Android view for most development work and use the Project view to view other project files that are not needed on a regular basis.
NOTE: Gradle is the build engine or tool that is used to create an app.
To see the actual directory structure, switch to the Project view (ALT+1 (PC) or CMD+1(Mac)). Android Studio project directory and file names that are always the same. If you hover over the top-level node, you will see the actual location of the project.
TIP: To see the actual folder in your file manager, right-click on the top-level item and select Reveal in Finder on the Mac or Reveal in Explorer on Windows.
NOTE: The other views arrange the structure for a particular perspective or purpose.
If you click on the top-level node, you will see all of the project assets:
The app folder is a module directory. Each project can have multiple modules with each module represented by a directory. To see what module(s) are included in a project, select File > Project Structure... and in the Project Structure dialog box that appears, in the left panel, you will see what Module(s) are included with the project:
This view presents Java classes and resource files all together in single tree format.
This view allows you to copy "scratches" of code that you can use later. To do this, copy some code and then from the menu select Tools > New Scratch File.... so that it appears in a new scratch file. Close the scratch file and then switch to the Android scope and then return to the Scratches panel. You should now see the scratch file listed.
Show files that need fixing. To test:
Show Java, resource and generated files that are required for production when the app is package.
Show files that are required for jUnit tests. To perform a test:
This test works with virtual and physical devices. To test:
There are a host of tabs that surrounds the Android Studio app. Simple click on one to view it.
The Structure tab (CMD+7 on Mac or ALT+7 on Windows) can be used to show a "structure" view of the Java classes along with their methods. They are shown by default in the order they are declared. However, you can sort them in any order you want (e.g., alphabetically, by visibility--access modifier). You can also determine what members of the class is going to be displayed. By default, you will see fields and non-public members.
The Captures tab can be used to "capture" the result of other panels (e.g., Memory) for review later.
The Build Variants tab can be used to "build" different "variants" of your app. By default, you will used the debug variant. However, when you are ready to publish your app for deployment, you will need to use the release variant to build your app.
The Favorites tab can be used to save your "favorites" classes and other resources that you like to use often. By default, you will see three items available (Project, Bookmarks and Breakpoints). You can add items to the Favorites from the one of the Project windows. Find what you want to save to Favorites and then right-click on it and select Add to Favorites and then add to the Project or to an New Favorite List. To open a Favorite, double-click on it.
The Message tab (CMD+0 on Mac or ALT+0 on Windows) can be used to provide a listing "messages" from the Gradle build tool. It is different from the Problems tab that is used for Java errors. The Message tab is used to display messages when the app is being built. Double-click on the TODO comment to have the cursor move to the place where the comment is. You can also filter your TODO comments based on the current file or a scope (e.g., Project, Android, Package).
The Android Monitor tab is used to access to logcat output. By default there is only the Memory monitor. However, if you double-click on the Android Monitor tab, it will allow you to view the CPU, Network and GPU monitors as well. However, these monitors will only be active when you are running a virtual or physical device. Whenever you run your app, the Android Monitor window will open automatically.
The TODO tab is used to show a list of "To Dos" that you want to write to yourself or others. In your Java code, to write a TODO start with a double slash, type the word TODO follow by a space and then the "to do" item (e.g., // TODO Add more code to this class later). The TODO will be shown in the TODO panel.
The terminal tab is used to open a command prompt. On Windows, it opens a simple command prompt and on the Mac, it opens the terminal app. You can run any command that you can on your Operating System (e.g., ls or dir for directory listing on the Mac and Windows, respectively).
The Gradle tab is used to ...
The Android Model tag is used to ...
The Android project window has a virtual folder called GradleScripts that contain two Gradle scripts and other configuration files in one place.
There are two build scripts with the SAME name, one is for the project and the other is for the module.
The AndroidManifest.xml is an XML file at the top level of the project that describes to the Android Virtual Machine (ARM):
There are several ways to access this file:
The structure of the manifest file is as follow:
NOTE: It is important to note that an app's configurations are split between the Gradle script and the app manifest file.
Every Android project has a res folder with a host of resource folders in it.
However, there are other resources that can be created (e.g., color, xml, transition) that can be defined in its own file manually or automatically with Android Studio. The SDK document describe these resources detail. To define a brand color that can be used in an app:
Android Studio's dependency system is based on the Maven repository which is a host of libraries where developers can add or download libraries. If you open the build.gradle file, you will see a list of support libraries in the dependencies directives. These libraries were automatically included when you selected the Support Repository checkbox when Android Studio was installed.
You can find the Support Repository by clicking on the SDK Tools tab in the SDK Manager, and then you'll see the Support Repository listed here. During compilation, the build process looks at these directives and unique identifiers for the libraries and the versions you want to use. First, it looks at the local repository copy of the SDK installation to get them. However, if it doesn't, it can be manually added from a remote repository.
If you want to work with JSON (JavaScript Object Notation) formatted data and wanted to use Google's GSON library to include as a dependency, you could follow these steps:
Gson gson = new Gson();
The bottom line is that you don't have to add a Java library (*.jar) to the projects folder and then adding it to the class path using this method. In the build.gradle file, notices there is a section on repositories that has a reference to a method called jcenter. If you hold down the CTRL or CMD key and then hover the cursor over this method, you see that it is returning an instance of the class named MavenArtifactRepository that is referencing the Bintray website. If you learn how dependencies work, you can add your own repositories to this list and expand the capabilities of the gradle build system.
There are several online open source libraries that are available for Android development. Type in a search field (e.g., gson) to search for a particular library.
Whenever possible, you should use dependencies that refer to remote files. However, that is not always the case (e.g., your own library or a third party library). So you have to add them manually to your project.
Beside adding a JAR file from remote library dependencies or local JAR file dependencies, another way is to "wrap" a JAR file or files with its own module. Which option you choose depends on the project complexity or your own preferences.
Once you have established your Android Settings (PC) or Preferences (Mac) to see its Appearance and Behaviors and if they get corrupted or you want to use them on another computer, you can export the current settings and then import them onto another computer so that you don’t have to go through the same steps again.
To import a project from Eclipse with ADT (Android Developer Tools), once you import the project, you will need to make some configuration changes to the build.gradle file to make is compatible with a current version of Android Studio.
Google provides useful documentation and training on-line at developer.android.com/develop, installed off-line documentation with the Android Studio installation or in-place documentation within code. These documentations allow a developer to learn the Android framework by Java Classes and APIs that can be searched or viewed by API version number or name. To access the in-place documentation of a selected Class, press CTRL+Q (PC) or F1 (Mac) or hold down the CTRL key and move cursor over a Class name.
On the developer website listed above you can find information on:
News - http://android-developers.blogspot.com/
Questions about Android and programming in general - http://stackoverflow.com/
Another way to test and learn how to use Android Studio is to import sample apps.
Android Studio also provide ways to integrate with many source control packages (e.g., CVS, Subversion, git) via add-ons which allow it to manage checking out files, etc. However, not all files are suitable for source control (e.g., files in the bin and gen directories).
To exclude these files, add some extensions to the exclusion list (e.g., *.apx, *.ap_, *.dex). [CONFIRM]