• Develop the first application

  • Are you excited to develop your own app? All right! Start a new Android Studio Project

  • Next, enter the app name (uppercase), the company domain, and specify the directory to store the app. Click Next to proceed:

  • If the first letter is not capitalized, it prompts:

The application name for most app begins with an uppercase letter
Copy the code
  • Next, you need to choose which device to develop the app on (mobile and tablet, Wear, TV, Android Auto, etc.) and determine the version number of the minimum SDK.

  • The Minimum SDK checks the Android version of the device before the application is installed. If the Android version of the device is lower than the Minimum version, the user is prevented from installing the application.

  • If you don’t know how to choose the smallest version, you can click Help Me Choose to see the distribution chart and description of each version:

  • Continue clicking on the Next button to proceed, we need to select the style of our first Activity from our image-friendly GUI template:

  • You then need to give your Activity and Layout a name.

  • After clicking the Finish button, Android Studio starts creating and compiling the application. After compiling, you can see the Android Studio IDE interface.

  • As you can see from the picture, Android Studio has helped us organize the project well.

  • Interface is introduced

  • As shown in the figure above, I divide the interface into five areas for detailed explanation:

  • This area is used to run and debug related operations.

  • Compile the module shown in 2

  • 2. List of modules for the current project

  • 3. Run the module shown in 2

  • 4. Debug the module shown in 2

  • 5. Module code coverage as shown in Test 2

  • 6. Debug android running processes

  • 7. Re-run the module shown in 2

  • 8. Stop the module shown in 2

  • Area 2 Introduction

  • This area is mainly related to Android devices and virtual machines

  • 1. Virtual device management.

  • Gradle files need to be synchronized when Gradle configuration is modified.

  • 3. Project structure and configuration of some project-related attributes.

  • 4. Android SDK management

  • 5, Genymontion simulator (need to install Genymontion plug-in, installation [simulator installation] part)

  • Area 3 Introduction

  • This area is mainly for project file resources and other related operations.

  • 1, show how files are organized in a Project. The default is Android. You can choose Project, Packages, Scratches, ProjectFiles, Problems… And so on display. I usually use Android and Project the most.

  • 2. Locate the current open file in the project directory.

  • 3. Close all expansion items in the project directory.

  • 4, some additional system configuration, click on a pop-up menu:

  • When Autoscroll to Source and Autoscroll from Source are checked, Android Studio will automatically locate the current edit file in the project, which will be very nice to use. Other functions you can explore your own.

  • Area 4 introduction

  • This area is mainly used for writing code and designing layouts.

  • 1. The Tab page of an open file. (Pressing Ctrl + clicking the mouse on the Tab page will bring up a pop-up menu. Surprise!)

  • 2. UI layout preview area.

  • 3, layout editing mode switch, for some old birds prefer to edit the layout through Text, novice can try to edit layout Design, edit and then switch to Text mode, for learning Android layout Design is very helpful.

  • Area 5 introduction

  • This area is mostly used to view some output information.

  • 1. Terminal – Partners who prefer command line operations do not need to start terminals.

  • 2. Monitor – You can view some application output information.

  • 3. Information – Some output information for the project compilation.

  • 4. Run – Some information about the application after it runs.

  • 5. TODO – A list marked with TOTO annotations.

  • 6. Events – Some event logs.

  • Gradle console, from which you can see the output of Gradle building applications.

  • Android Studio directory structure

  • Gradle compiles the system with the version specified by Wrapper

  • 2. Files required by Android Studio IDE

  • 3. Directory for storing application-related files

  • 4. Relevant files generated after compilation

  • 5. Store related dependent libraries

  • 6. Code storage directory

  • 7, resource file storage directory (including: layout, image, style, etc.)

  • A list of basic information about the application, describing which components are present

  • 9. Git version management ignores files and marks which files are not needed in git repositories

  • Android Studio project files

  • 11. Gradle configuration of modules

  • Configure code obfuscation rules

  • 13. Gradle configuration of the project

  • Gradle global properties

  • 15. Local property setting (key setting, Android SDK location and other properties)

  • Application development and debugging

  • Click Set breakpoint at the line number you want to Debug as shown in figure 1, and then click the Debug button as shown in figure 2 (or simply press Shift+F9) to start debugging.

  • The debug view appears below Android Studio as shown above.

  • 1. The line of code that the current program stays on

  • 2. Debug related buttons

  • 3, program call stack area, this area shows the program execution to the breakpoint point called all methods, the lower the earlier the call.

  • 4. Observation area of local variables

  • 5. User-defined variable observation area

  • Step Over(F8) – The program moves down a line, returns if the current line has a method call, and then moves on to the next line.

  • Step Into(F7) – The program executes down a line and enters the method if the current line has a user-defined method (unofficial library method) called.

  • 3. Force Step Into(Alt+Shift+F7) – The program moves down a line and enters the method if there is a method call on the current line.

  • 4. Step Out(Shift+F8) – If you enter a method while debugging and find it ok, you can Step Out of the method and return to the next line where the method was called. It is worth noting that this method has been executed.

  • 5. Drop Frame – After clicking this button, you will go back to the call of the current method and execute again, with all context variables returning to that time. As long as there are parent methods in the call chain, you can jump to any of them.

  • 6, Run to Cursor(Alt+F9) – Run until the Cursor is at the same position.

  • Resume Program (F9) – Run the Program until the next breakpoint is hit.

  • 8. View Backpoints (Ctrl + Shift +F8) – View all breakpoints you have set and set some properties of breakpoints

  • 9, Mute Backpoints – after selected, all breakpoints are set to invalid state. Click again to reset all breakpoints valid.

  • After clicking the View Backpoints button, a breakpoint properties window appears, allowing you to do some more advanced Settings on breakpoints.

  • 1, lists all breakpoints set in the program

  • 2. Conditional breakpoints can be useful in the actual development process if you enter a condition and the breakpoint takes effect only after the condition is established (for example, enter I == 8 in the input box). Conditional breakpoints can also be set by right-clicking on breakpoints, as shown below:

  • Ok, here is the debugging related functions are introduced.

  • Application packaging signature

  • basis

  • In an Android Studio project, there are multiple. Gradle files. Gradle file exists in the project directory and build.gradle file exists in each module.

– Build. Gradle in the project

Buildscript {repositories {jcenter() // Declaration of Maven repository} Dependencies {// Android provides 2.0-alpha5 gradle build The classpath 'com. Android. Tools. Build: gradle: 2.1.0 - alpha5'}} / / for all project repositories configured for jcenters allprojects {repositories Task Clean (type: Delete) {Delete rootproject.builddir} task clean(type: Delete) {Delete rootproject.builddir}Copy the code
  • Build. gradle in the module
// This indicates that the module is an app Module apply plugin: 'com.android.application' android {// Which version to build compileSdkVersion 23 // Which build tool version to build buildToolsVersion "23.0.3" // The default configurations include: App ID, minimum SDK version, target SDK version, DefaultConfig {applicationId "open_open.com.helloWorld" minSdkVersion 10 targetSdkVersion 23 versionCode 1 VersionName "1.0"} // buildTypes is a build type, usually release and debug, in which obfuscation can be enabled, zipAlign can be enabled, and signature information can be configured. buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}} dependencies Defines jar, AAR, jCenter libraries that the module depends on. dependencies { compile fileTree(dir: 'libs', include: [' *. Jar ']) testCompile junit: junit: '4.12' compile 'com. Android. Support: appcompat - v7:23.2.1'}Copy the code

Packaging signature

Select Build->Generate Signed APK… , as shown below:

In the popover, continue Next until you reach the following screen:

  • In the absence of a Key, we can start by clicking Create New… Button to create a Key, the process is very simple, as shown below:
  • If you already have a Key, click Choose Existing… Button to specify the.jks file location as shown below:
  • Enter the Key Store Password and Key Password (the two passwords you entered when creating the Key) and click the Next button:
  • Click Finish and wait for the signature to complete. When the signature is complete, the AS will prompt us:
  • Click Show in Explorer to find our signed APK file:
  • //////////////////////////////////////////////////////////
  • Original link: www.apkbus.com/blog-822715…