Android Development Study Notes-01 The first Android application

1. Create your first Android application

Create an Android application project based on Android Studio 3.5.2.

  1. Open AS and choose to create a new AS project:
  2. Select the option to run the hardware platform and the Activity template, and click next:
3. Enter APP-related information, select a development language, set the minimum API level, and click Finish to complete:

The minimum API level here is selected according to the development needs. The coverage of devices that can run at different levels is different. I choose 5.0 here.

After the above steps are completed, Android Studio will automatically perform the first project build and synchronize the corresponding gradle. But gradle is hung on the external network, the download speed is slow, and various magical problems often occur. If it is not possible, go to the gradle official website to download the corresponding gradle version, put it in the corresponding path, and then open the project for synchronous construction.

Download link: gradle official website

For example, my gradle path:

insert image description here

Note: The version of gradle is not necessarily the same for everyone, just download the corresponding one, the downloaded one is the zip compressed file of all, no need to decompress it

2. Android project panel introduction

The Android application engineering interface after successful creation and construction:

insert image description here

  1. Introduction to the functions of each part of the AS engineering interface:
    it can be roughly divided into 5 parts:
    insert image description here
  • Engineering view:
  • layout layout interface:
    insert image description here

3. Connect Android phone

  1. Open the mobile phone developer options (I can't find Baidu), find and open USB debugging, and connect to the computer with a USB data cable;
  2. Select the option to transfer files, select Allow for pairing, and the toolbar will display the device name after connection, such as:
    insert image description here

3. Click the Run triangle symbol on the right side of the device name to run the current APP. The interface for installing the APP will pop up on the mobile phone. After installation, open it to see the effect of the written APP.
insert image description here

HelloWorld App effect:

The simple calling process of the HelloWorld application:

MainActivity类-> OnCreate方法
The source code is as follows:

package com.example.helloworld;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
    
    

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

You can see OnCreatethat the method is called setContentView, and activity_main is set, which is the layout file of activity_main.xml. This is the simplest Android application running process.

The latest version of Android Studio is above 4. It is said that the 3.5.2 version is relatively stable. After stepping on a lot of pitfalls, I use 3.5.2. The download link: AS中文网

Guess you like

Origin blog.csdn.net/qq_41790078/article/details/113405061