Android Studio Bumblebee version usage introduction
Bumblebee version introduction
Recently, I updated AS to the latest version: Bumblebee | 2021.1.1 Patch 2 , the download address of AS is: Google China , this version will be updated in February 2022.
If you have installed the old version before, it doesn't matter, just overwrite the installation, some previous configurations will be synchronized in the new version, let's start AS.
This is the splash page, bumblebee version, I was using AS 4.2.1 before. Now update to the latest version and let's see what's changed. Create a project to test it out:
Create the project still nothing changes, let's see what changes to the project structure. Every time AS is updated, Gradle is changed with it, so let's take a look at this change first.
1. Introduction to Gradle
① Project build.gradle
First of all, the directory of the project has not changed. First of all, the build.gradle of the project is
not the same as the previous one. Do you remember what it was like before? Like the picture below.
You can see that there are versions of the library and gradle in the previous one, and now there is only one version of application and library. So where did the previous content go, in fact they are in settings.gradle
② settings.gradle
There are two more parts in this settings.gradle, one is plugin management and the other is dependency resolution management. You can see here that there is no jcenter() library, but only mavenCentral(), which means that jcenter() is completely deprecated in the new version, and mavenCentral() is used by default. In addition to this library, we are also developing The jitpack library will be used, so where should this library be added? It can be added as shown below.
In fact, the build.gradle under the module has not changed much in this gradle update.
③ Use of Hilt component library
There are also some special libraries that are added and used in different ways. Here I will give an example, taking the Hilt component of JetPack to illustrate: first, change the build.gradle of the project, and add the following code in it:
buildscript {
ext {
hilt_version = '2.28-alpha'
}
dependencies {
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha'
}
}
The addition location is shown in the figure below:
Then go back to the module to be used, such as the app module, open the build.gradle of the app module, and add the plugin shown in the figure below in the plugins closure.
Add dependencies in dependencies.
Finally Sync Now.
2. Device Manager
Many times in the development process, we will use virtual machines to perform some simple tests. At this time, you need to use the device manager to create virtual devices.
Click the phone icon on the menu bar to open the device manager. It used to be a separate pop-up window, but now it is displayed directly in the editor. Then we can create a device and click Create device.
① Android 12 experience
The place still hasn't changed much, it's the same as before. After selecting a size for the model, click Next.
Then select a running Android system for the virtual machine. Here you can see that Android 12 is already supported, and the corresponding API is 31. At the same time, the shipwreck has seen a pre-beta version of API 32, which shows that Google is moving forward like Android 13.0. If you haven't downloaded 12.0, you can download one. Remember to put the download directory on the disk you think is the system disk, because it will take up a lot of memory. Here I choose 12, then Next.
Then click Finish. Complete the creation of the virtual machine.
Because I have created a virtual machine before, so I don't need to create it again. Let's start the virtual machine.
Click this button to start it. The first startup will take a long time, please be patient.
You can click - in the upper right corner and Device Manager in the sidebar to close the area above.
This looks relatively normal, and then we run the current project.
② JDK 11 configuration
Then you will find that the project will report an error, why? Because the current Gradle version is too high and the configured JDK version is too low to meet the requirements, you need to upgrade the JDK to version 11 and above. This problem is easy to solve, just download, install and configure JDK11, which is similar to configuring JDK1.8. After configuration, corresponding changes are also required in the project.
File → Settings
can see that I am still 1.8 here, click the drop-down to select.
You can choose the JDK11 installed by yourself, or you can choose the JDK11 that comes with Bumblebee if it is not installed. Run as shown below:
③ Modify the resource download address
In fact, this problem can also be modified in the previous version, but I have not found a suitable opportunity to explain it, so I will introduce it by the way through this introduction. As an Android developer, does your system disk often run out of memory?
If you have never configured it before, then part of your C drive space is the Android Gradle files and emulator files. They occupy up to 10 GB of memory, or more. You can open the C drive to see that there is a large file in your user folder, and .android and .gradle occupy the most memory.
So how to modify their default download storage location? It is also modified through system environment variables. Because the AS is installed under the Android folder of the D disk, so I put these resource files under Android. If it is a virtual machine, then create a new AVD folder under the Android folder. like.
Variable name: ANDROID_SDK_HOME
, remember to confirm after changing it here, and then modify the default download address of gradle.
Note that the variable name should not be mistyped: GRADLE_USER_HOME , and another one that takes up a lot of memory is the Android SDK, which is easy to change,
you can change it any way you want. After the change, close AS, and then you can delete .android and .gradle under your C drive. Finally, shut down and restart, and reopen AS.
3. Build APK
The new version does not need to check two options when building APK.
Let's look at the previous version again, this is a picture I found from another article of my own.
Previously, the above two options were checked here, but they are not used in the new version.
Fourth, wireless debugging
In the previous version, there was a plug-in that supports wireless debugging. In this Bumblebee version, the official directly added wireless debugging, but it needs to be Android11 and above. If it is as shown below:
Click Pair Devices Using Wi- Fi
If you are using Android 11, 12 mobile phone can enter the developer options.
There is a wireless debugging here, turn it on.
Since I don't have a mobile phone with Andrdoi 11 and 12, I can try it myself if I can.