About Android studio upgrade to 2021.1.1 (Bumblebee) to create projects, compatible with the problems encountered in old projects-CSDN Blog

After upgrading to the AS Hornet version, I found that some configuration files had changed when I created a project or needed to be compatible with the old project. 

1. In the Bumblebee version, you will find that when you introduce other third-party packages through dependencies ( Failed to resolve ), the compilation will warn that the project to be imported cannot be resolved.

At this time, you may need to add the attribute allowInsecureProtocol = true to the project settings.gradle file and then configure the file as shown below:

2. After upgrading the original build.gradle file  , I found that the build.gradle file looks like this

 The repositories method has been moved to the settings.gradle file. The gradle.properties file needs to add this attribute android.enableJetifier=true

3. Could not find the location of the plugin classpath

The original previous project added the classpath parameter in build.gradle to dependencies, as shown below

But after the upgrade, it is found that it is as follows

The solution is to continue to add the classpath parameter in dependencies in build.gradle, as shown below.

The specific reason is: the writing method here is completely different from the old version, and it is written in Kotlin DSL syntax.
At this time, I need to add the classpath parameter to the project, but I can’t find the place to add the classpath, which is more difficult. I searched the gradle documentation: gradle documentation and   was told that I only need to build.gradle in the project root directory Add the corresponding dependencies in the above figure as shown

4. The parameters of the build file are unified

It is still the original writing method, because of some minor changes, I will find information later

Add the following code to build.gradle under the project file, and the parameters can be defined by yourself

ext {
    kotlin_version = "1.6.10"
    applicationId = "com.demo.javamvvm"
    compileSdkVersion = 33
    minSdkVersion = 21
    targetSdkVersion = 33
    versionCode = 1
    versionName = "1.0"
}

 Then the following is the direct reference of the build.gradle file under the App file is rootProject.ext.XXX

5. The build.gradle of the original previous project, whether it is a dependency or the main project, will refer to something like the following

1).apply plugin: 'com.android.library'

2). The replaced text is as follows

plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'kotlin-kapt'
}
现在换成如下的包名了
plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
    id "org.jetbrains.kotlin.kapt"
}

I have encountered problems before, and I have consulted a lot of information. I hope it can help others, if there is any need for improvement, please leave a message, thank you!

おすすめ

転載: blog.csdn.net/qq_27489007/article/details/130136748