On the way to update Android studio 3.0

Preface: as a leading biological "ape" in the world, how can we know nothing about new things? On October 26, with the release of the preview version of Android 8.1 Oreo and the official version of Android studio 3.0, as apes of Android development, we should have known that Google said to support kotlin language at the developer conference in May this year, So a big point of this update is that it supports kotlin language. Let's follow LZ's footsteps to explore AS3.0

I believe many people have experienced the experience version released by Google's father for a long time. Although the official version has been released, many people dare not update it rashly because they are afraid that they will fall into the pit and can't get out (it's really a timid ape, after identification)

install

If you click Update from within Android studio, you will jump to the official Android website. Students without a ladder can go to this website to download updates:

Problems encountered during the installation of Android studio 3.0 official version

1、Gradle Sync Failed:

In fact, it was not this fault at first. At first, it was a redownload fault. Later, LZ deleted version 2.3, cleared the cache, and then it became this fault. Since there is a mistake, solve it. Baidu has a good one. Let's take a look at the stack overflow solution

This method is also applicable to me. It's OK after demoting butterknife. If there are other better solutions, please send me a private letter and give me a paid red envelope. "The solution of one problem is to better meet the emergence of the next problem" -- Lu Xun

Solution 1: downgrade the butterknife that the project relies on to 8.4.0 solution 2: reduce the gradle plugin version to 2.3.3 and recompile it (thank you for being a little black youth here)

2、Unable to resolve dependency for:

When I first saw this mistake, I thought I didn't rely on appcommon in setting.gradle. After reading it, I clearly did. Moreover, this is an old project, which was very normal in as2.3. Then I knew it was another pit. I reluctantly went to the Internet, and then tried to add the preview node in buildtypes, However, there was no use. After checking for a long time, I still couldn't find a solution. Later, when I looked at this error message, I saw signingconfigs. I thought that there seemed to be such a node in gradle. With the attitude of trying, I deleted that node. Then, I laid the slot and the slot can be compiled successfully. Is there a catch-up of lying in the pit. If there are other better solutions, please send me a private letter and give me a paid red envelope

Solution: just delete the signingconfigs node in the project. If you are worried about multi-channel packaging, use the packaging tool.

Here are some problems encountered by friends in the group:

3、app:transformDexArchiveWithExterLibsDexMergeForDebug

Solution: delete the. Gradle directory in the computer (clear the gradle cache) and rebuild.

Reference stackoverflow

The solution is explained here

4. Gradle is packaged, and the user-defined APK name code reports an error (cannot set the value of read only property 'outputFile')

Solution: modify the file name code, please write it like this

Solution: turn off appt2 compilation in gradle.properties

5. Aapt2 compilation error

Solution: turn off appt2 compilation in gradle.properties

Note: if it is a project transferred from eclipse to as, there may be no gradle.properties file. Please create it manually in the root directory of the project

6. Error: cannot choose between the following configurations of project: MyLibrary:)

Solution: as follows

Well, these are some of the problems encountered in the recent update of 3.0.

Android Studio 3.0

1. . gradle file

Wow, after the problem is solved, I want to quickly create a new project to see what changes have been made. First of all, the. Gradle file has changed greatly:

We can see that Google dad "killed" the build tool version of buildtoolsversion. In the previous version, buildtoolsversion also brought a lot of mistakes to the construction of the project. Now Google dad "killed" it; What's more, the following dependencies are replaced by implementation. What's the difference between it and compile? Don't worry, have a cup of tea and listen to me carefully:

Compile and API

API is exactly the same as compile, and there is no difference between them. As we all know, with the update of Android version, there are many outdated classes and methods, and so is compile. We can understand compile as the past tense of API.

API and Implementation

These two are new instructions in AS3.0. The following figure illustrates the difference between the two:

Picture reference

If you want to know more, please refer to the official website

2. Kotlin support

Blessed are those who are still beginning to learn kotlin language. AS3.0 supports the direct conversion of Java code into kotlin code. Let's learn about this function through a VCR:

In the java file, select the code you want to convert, and then select code - > Convert java file to kotlin file at the top to convert. After conversion, this is a kotlin file.

3. Logcat column

In the previous versions of as, when logcat was still Android monitor, there were many things in it, such as network, memory and CPU. In AS3.0, Google separated it, and logcat was put out separately. The previous one looked at the network, memory and CPU separately. One thing called Android Profiler:

Isn't it handsome? It's said that this thing also has its own bag capturing function (this is LZ's favorite function). It's only turned off by default. We have to turn it on manually. Enter run - > Edit configurations, and then hook the following:

It should be noted that the API version in your project must be below api26, and your mobile phone version must be above Android 5.0 to use the packet capture function. After opening, let's grab a bag and try:

When a network request is initiated on the mobile phone, the network column will change obviously. We select that area for packet capture, and we can see that an interface mainservlet is requested (if multiple interfaces are requested in this area, it will be listed one by one). Then we click mainservlet, and the information such as JSON and header from the background will appear. How about it, Isn't it great that you can record the data of the current page, and you can also analyze it according to the data recorded in other software such as CPU and memory. These two will not be displayed. Interested students can play by themselves after updating. Finally, it should be noted that opening this will reduce the construction speed of the application, so enable it only when you want to start profiling the application.

4. File manager

In AS3.0, the file manager tool allows seamless interaction with your as connected mobile phone. You can view, copy and delete files on your device on AS3.0. It is very useful when checking files created by applications or transferring files to devices:

5. Support Java 8

Similarly, students who like to write lambda also have benefits. This revision of as supports java8 and can directly format java code into lambda format. However, you have to set your project to support java8. Right click your module and select open module settings. After entering, follow the following settings:

In this way, you can use lambda expressions. The system will automatically remind you where to convert to lambda expressions. Is it smart

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>