foreword
The last time I did Android development was in the third-year Android class project " IPOD - Local Music Player "
- Development environment: JDK
- Development language: Java
- Development tools: Android Studio
Now because the work requires "business-oriented programming" , I need to resume Android development. Since the computer has been changed, I decided to re-open an Android column and record learning essays at the same time. Welcome to subscribe~
JDK installation configuration
Regarding
JDK
the part of installation & configuration, there are many perfect articles on the Internet, so I won’t repeat them too much.
- Go to the official website to download and install, then "configure environment variables"
- If you don't know how to find it, just download it here (password:
@Wriprin
)
- If you don't know how to find it, just download it here (password:
java -version
& javac
Test whether the configuration is successful
Android Studio installation configuration
After the download is complete, run the program to install Android Studio Setup
, modify the "installation path" and wait for the installation to complete
Here select "Do not import settings"
Next, configure the download path of regular dependencies such as SDK, etc. Here, select "Custom" , and it is recommended to configure a place other than the C drive
By default, it will point to the directory at the same level as the program installation path, just click Next
Configure the SDK installation directory
The installation configuration is summarized as follows:
-
You can switch "Global {over} proxy {filter}" to download, and then wait for the download to complete
-
If you don’t have the conditions, you can find relevant packaged SDK packages on the Internet and download them directly to the local configuration. I won’t go into too much detail about this part, and you can find relevant resources by yourself if necessary.
Regarding the problems AMD will encounter, solutions: Android-emulator-hypervisor-driver/issues
HelloWorld
Initial Welcome interface - "New Project" - create a project
Let's choose one here Empty Actity
to do the initial project construction
The project configuration is related, and the specific configuration is shown in the following figure:
You can see that the project structure on the left has been Loading..., click Build in the lower left corner and you can see that AS is downloading Gradle and some other related dependent jar packages and other files for us, just wait patiently
-
If the download is complete and the project is built, you will be prompted to
Error
report an error -
Then it is recommended to click "Try again" and try
Sync
again. It may be that some dependencies were not successfully downloaded during the last build, which largely depends on your network environment. If there is no relevant proxy environment for this, then I can only say that I will do my best. -
PS: If
HelloWorld
such an empty project can't run, it's really a ghost :-(
The first is MainActivity
the startup class: which onCreate()
loads the style file activity_main.xml
(used to build the page layout style)
package cc.cnix.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);
}
}
In addition, you also need to know that AndroidManifest.xml
the (startup) class is configured in
<application>
<activity>
<!-- 配置启动类 -->
</activity>
</application>
AS default configuration modification
AVD installation configuration
Android development tests can pass:
- Test with a real device (USB connected to an Android device (with ADB debugging enabled), MUMU, Thunderbolt...)
- Use the built-in AVD (Android Virtual Device) Android virtual device test
- Use Virtual Box + Genymotion to build virtual machine debugging
The smooth operation of AVD requires three hardware conditions:
- x64-bit CPU that supports virtualization
- 8 GB or more of RAM
- 20 GB or more of free disk space
At the same time, you also need to confirm that the virtualization function of the CPU has been turned on in the BIOS settings
First configure the Gradle JDK, using the "embedded"JDK version 11.xx.xx
Then select "AVD Manager"
Create Virtual Device, then select the AVD model configuration
Select the required API version and download the system image "Tested - 28 - Pie - 5.0 is valid"
After the download configuration is complete, start the HelloWorld project
So far, the environment construction and basic configuration of Android Studio have been completed~