Android Studio

Download and install

Download address

Mac

Configure the SDK download path

After installation

Open the Settings

Uncheck Match case and ignore case when prompted

JDK download and installation, environment variable configuration

Java SE Development Kit 8 – Downloads (oracle.com)

Foolproof installation

Environment Variable Configuration

MAC
open .zshrc
Copy the code
Open. Add code ZSHRC file export JAVA_HOME = / Library/Java/JavaVirtualMachines jdk1.8.0 _181. JDK/Contents/HomeCopy the code

Running at terminal

java -version
Copy the code

If this screen is displayed, the JAVA environment variables are configured successfully

Android SDK download and environment variable configuration

Pick the SDK version you need and download it

Running at terminal

adb
Copy the code

If this dialog box is displayed, the SDK environment variables are configured successfully

Introduction to Android Studio plug-ins

.ignore

Git ignore file template plugin

BugKotlinDocument

This plug-in is used to quickly generate comments for Kotlin code

JSON To Kotlin Class

This plug-in quickly generates Kotlin’s data classes from JSON

RoboPOJOGenerator

This plug-in quickly generates Java entity classes from JSON

Translation

This plug-in can quickly translate selected text and can also quickly view document translations

Android project creation and related directories

Create a project

The first step is to select it and click Next

Step 2 Configure basic information

  • Name: indicates the project Name
  • Package name: The project Package name must be unique and must start with a letter, number, and underscore (_)
  • Save Location: Where the project is stored
  • Language: Select the development Language: Java and Kotlin are optional. Kotlin is recommended
  • Minimum SDK: Select the lowest supported Api version. Currently, Android6.0 Api23 is used

Click Finish to create and wait for the project to complete

  1. .gradel and.idea are automatically generated files, don’t worry about them
  2. App is the code, resources and other contents in the project are almost all placed in this folder, and our development work is also carried out in this directory
  3. Build mainly contains files that are automatically generated at compile time, so don’t worry about it (the latest development tools don’t have this folder)
  4. Gradle directory contains gradle Wrapper configuration files. Gradle Wrapper configuration files do not need to be downloaded in advance. Gradle Wrapper is not enabled by default. Configuration changes can be made via the Studio navigation bar →File→Settings→Build, Execution,Deployment→Gradle.
  5. .gitignore is used to exclude specified directory files from version control
  6. Build. gradle Gradle build scripts for the global project
  7. Gradle. properties Is a global Gradle configuration file whose configuration properties affect all gradle compilation scripts in your project
  8. Gradlew and gradlew. Bat are used to execute gradle commands from the command line, the former for Linux/Mac and the latter for Windows
  9. Iml iml file is a file automatically generated by all IntelliJ IDEA projects (developed by Androidstudio based on IntelliJ IDEA). There is no need to modify any content of this file
  10. Local. properties is used to specify the path to the AndroidSDK
  11. Settings. gradle this file is used to specify all imported modules in your project. Since there is only one app module in the HelloWorld project, the app module is the only one introduced in this file. The introduction of modules is usually done automatically, and there may be few scenarios where we need to modify the file manually.
Directory under module APP
  1. The manifest directory contains the Android manifest.xml file, which is the configuration file for the entire project. All four components defined in the application need to be registered in this file. You can also add permissions to applications in this file. The four components of the system are activities, services, Broadcast Recevier and Content providers.
  2. JAVA directory
    1. MainActivity
    2. Android Test, used to write Androidtest Test cases, can carry out some automated tests on the project
    3. Test, used to write Unit Test test cases, is another way to automate testing of projects
  3. Res directory
    1. Draw able directory: Store pictures
    2. Layout Directory: Stores the layout
    3. Values directory: Stores strings
  4. Build. gradle file: This is the Gradle build script for the app module. This file specifies many configurations related to the project build.
  5. The proGuard-rules. pro file is used to specify the obfuscation rules for the project code. When the code is developed, it is put into the installation package file. If you do not want the code to be cracked, the code will be obfuscated, making it difficult for the cracked code to read.

Git

Git download and installation

Mac

If you’re developing on a Mac, there are two ways to install Git.

First, install Homebrew and then install Git through Homebrew. For details, refer to the homebrew documentation: brew.sh/.

The second, simpler and recommended method is to install Xcode directly from the AppStore. Xcode integrates with Git, but it is not installed by default. You need to run Xcode, go to “Xcode” -> “Preferences”, and find “Downloads” in the popup window. Select Command Line Tools and click Install to complete the installation.

Win

Download address

  1. Downloading the Installation package

  2. Running the installation package

  3. Click Next until Install appears, click Install, and click Finish when the installation is complete:

    1. Click the right mouse button on the desktop to display the following interface

    2. Check that Git is installed OK

      Key Ctrl+ R, then in the pop-up box to access CDM, the following interface is displayed, enter git, press Enter

    3. After the installation is complete, you need to enter the following step on the command line:

      $ git config --global user.name "Your Name"
      $ git config --global user.email "[email protected]"
      Copy the code

      Because Git is a distributed version control system, every machine must identify itself: your name and Email address

Basic use of GitGit Tutorial – Liao Xuefeng’s official website (liaoxUEFeng.com)

Workspaces, staging areas, and version libraries

  • Workspace: the directory you see on your computer

  • Git repository: A workspace has a hidden directory, git, which is not a workspace, but a git repository.

    Git’s repository contains a number of things, the most important of which is a staging area called stage (or index), the first branch that Git automatically creates for us, master, and a pointer to master called HEAD.

Git Git

We select a location to create an empty directory:

a@192 learning-notes % mkdir learngit
a@192 learning-notes % cd learngit 
a@192 learngit % pwd
/Users/a/Desktop/learning-notes/learngit
a@192 learngit % 
Copy the code
  • Git init: Run this command in the specified directory to change the directory into a git repository, which will generate a.git directory. This directory is used to keep track of git repositories

    A % @ 192 learngit git init initialized empty git repository to/Users/a/Desktop/learning - notes/learngit /. Git/a learngit % @ 192Copy the code

    Create a readme. TXT file in this directory and write the following:

    Git is a version control system.
    Git is free software.
    Copy the code
  • Git add: Use this command to tell Git to add files to the repository

    a@192 learngit % git add readme.txt a@192 learngit % 
    Copy the code

    Execute the above command, nothing is displayed, that’s right, the Unix philosophy is “no news is good news”, indicating success.

  • Git commit -m: tell git to commit the file to the repository:

    Git commit -m: git commit -m: git commit -m: git commit -m: git commit It is strongly requested that update information be entered

    a@192 learngit % git commit -m "wrote a readme file"[master (root submission) 1fd6A0d] wrote a readme file 1 file changed, 2 insertions(+) create mode 100644 readme.txta@192 learngit %Copy the code

    Git commit: 1 file changed: 1 file changed (our newly added readme.txt file); 2 insertions: Two lines are inserted (readme.txt has two lines).

    Modify the readme. TXT file to the following:

    Git is a distributed version control system.Git is free software.
    Copy the code
  • Git status: This command allows you to keep track of the current status of your repository

    a@192 learngit % git status Changes in the branch master that have not yet been temporarily saved for submission: Update the content to commit using "git restore < file >..." Discard workspace changes) Changes: Readme.txt changes have not been added to commit (use "git add" and/or "git commit -a") a@192 learngit %Copy the code

    This output tells us that readme.txt has been modified, but no changes are ready to commit.

    Although Git tells us that readme.txt has been modified, it would be nice to see exactly what has been changed. Git diff git diff git diff git diff git diff git diff

  • git diff:

    a@192 learngit % git diffdiff --git a/readme.txt b/readme.txtindex d8036c1.. 013b5bc 100644-- a/readme. TXT ++ b/readme. TXT @@-1,2 +1,2 @@-git is a version control system version control system. Git is free software.\ No newline at end of filea@192 learngit %Copy the code

    Git diff (difference) git diff (difference) git diff (difference) git diff (difference) git diff (difference) git diff

    Once you know what changes you’ve made to readme.txt, you’ll feel better about committing it to the repository

    a@192 learngit % git add readme.txta@192 learngit % git status Changes to commit in branch Master: (Use "git restore --staged < file >..." To cancel temporary storage) modify:  readme.txta@192 learngit % git commit -m "add distributed"[master 3ffecb6] add distributed 1 file changed, 1 insertion(+), 1 deletion(-)a@192 Learngit % a@192 Learngit % git status Located in branch Master no files to submit, clean workspace a@192 Learngit %Copy the code
  • Git log: displays commit logs from the most recent to the most distant

    a@192 learngit % git logcommit 3ffecb678e324ee6078f4c6c6bbdfc688c684136 (HEAD -> master)Author: 沐枫 <[email protected]>Date:   Sat May 8 11:04:10 2021 +0800    add distributedcommit 1fd6a0d268f50e09501a0e72e7d695c3915d2d55Author: 沐枫 <[email protected]>Date:   Sat May 8 10:51:47 2021 +0800    wrote a readme filea@192 learngit % 
    Copy the code
  • Git reset –hard HEAD^: retracting the previous version of git to HEAD^ and the previous version to HEAD^.

  • Git reset –hard 3ffec: This command goes back to the specified version. 3ffec is the first bit of the commitid submitted, and Git will automatically look it up

  • Git reflog: Record every command you make

  • Git remote add origin xxxxx.git: associate local repository with remote repository

  • Git push -u origin master: push the contents of the local repository to the remote repository

  • Git remote -v: displays remote library information

  • Git remote rm origin: Delete the remote library named Origin

  • Git clone XXXXXX

branch

  • Git checkout -b dev: Create the dev branch and switch to the dev branch

    Git checkout: git checkout: -b

    git branch devgit checkout dev
    Copy the code
  • Git branch: View the current branch

    The git branch command lists all branches, with the current branch preceded by an asterisk

  • Git checkout Master

  • Git merge dev: merge the contents of the dev branch into the master branch

  • Git branch -d dev: After the merge, you can delete the dev branch

Note: The latest version can switch branches using switch

  1. Create and switch to a new branch git switch -c dev
  2. Go directly to the branch git switch master

Resolve the conflict

Conflicts occur when merging branches or fetching code from the remote library, and we need to find the conflicting files and manually resolve the conflicts before recommitting and pushing them to the remote library

Use Git with AS

  1. Configure git

2. Configure Github and bind the Github account

Clone code from remote libraries using AS

Two entrances

  1. On the AS startup screen, select the entry in the red box

2. In the open project, click the top menu VCS -> Get from Version Control

  1. Open the interface

In the Url field, type the location of the remote library to clone. In Directory, select the location where the clone code will be saved

  1. Open the Clone project in AS and you can see the position marked in the red box below

  • A Git: arrow and checkmark position at the top is a quick entry point for pulling and submitting code
    • Arrow: quickly pull the code, and merge the code to the local, if there is a conflict we need to manually resolve the conflict
    • Check: Fast commit code, click, will open the commit bar on the left
  • Commit the sidebar: Open the sidebar to display the files we have updated, deleted or added. There is a Commit Message input box below the file for us to input the updated content. There is a Commit button in the lower left corner of the input box, where we can Commit the selected modified file. Clicking the arrow will bring up two action buttons
    • Commit: Commits the modified code to the staging area
    • Commit And Push: Commit And Push to the remote library
  • Bottom Git: The left side shows all branches, both local and remote, and the right side shows the code commit history

Associate a local directory with a remote repository

  1. Open the Git server and create a remote repository

  1. Open the project with AS

  2. Open the top menu VCS -> Import into Version Control -> Create Git Repository… To make the directory a Git local repository

    The top appears

  3. Right-click the root directory and add all files to Git -> add

  4. Click the check to submit the code to the staging area

Click Define Remote to associate the remote repository

The association succeeds, pushing the modified code to the remote end

Push success

View the remote repository