Android studio的Bumblebee版本Gradle7.2降到Gradle4.2.0详细步骤记录(项目已上传)

目录

基础信息

修改必须的配置文件

settings.gradle

build.gradle(Project)

build.gradle(Module)

gradle-wrapper.properties

gradle.properties

其它错误

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

调试报错

注意事项

总结


基础信息

Android Studio Bumblebee | 2021.1.1 Patch 3

Android Gradle Plugin Version:7.1.3

Gradle Version 7.2

在Android Studio Bumblebee 新创建的项目,名为MiSController

修改必须的配置文件

settings.gradle

根据下面截图进行注释。

build.gradle(Project)

添加如下代码,并注释掉7.1新的特性和规则代码

//plugins {
//    id 'com.android.application' version '7.1.3' apply false
//    id 'com.android.library' version '7.1.3' apply false
//}

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(Module)

plugins {
    id 'com.android.application'
}

//android {
//    compileSdk 32
//
//    defaultConfig {
//        applicationId "com.jsdl.miscontroller"
//        minSdk 21
//        targetSdk 32
//        versionCode 1
//        versionName "1.0"
//
//        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//    }
//
//    buildTypes {
//        release {
//            minifyEnabled false
//            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//        }
//    }
//
//    compileOptions {
//        sourceCompatibility JavaVersion.VERSION_1_8
//        targetCompatibility JavaVersion.VERSION_1_8
//    }
//}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"
    defaultConfig {
        applicationId "com.jsdl.miscontroller"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

gradle-wrapper.properties

7.2改为6.7.1-bin,如下图:

gradle.properties

注释掉“android.nonTransitiveRClass=true”

主要解决这个错误“The option setting 'android.nonTransitiveRClass=true' is experimental.
The current default is 'false'.”

 Sync Now后完美解决所有警告和错误;

其它错误

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

使用sdk为Android12版本会报警告错误,解决方法:

找到sdk安装路径 "E:\AndroidStudio\sdk\build-tools\31.0.0"
把d8.bat改为 dx.bat 
把d8.jar改为 dx.jar

改为后记得重启AS

调试报错

The minCompileSdk (33) specified in a(CheckAarMetadataTask.kt:146)

build.gradle(Module)的defaultConfig里加入:

configurations.all { resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' } }

 

 

注意事项

切记不要在“Project Structure”里改,不然绝对各种报错!

总结

为了方便大家我已经把项目打包。

增加包结构名称;

增加支持kotlin开发;

为了方便理解,相关高版本的配置并未删除,只是注释掉了;

项目下载地址: AS纯净Android项目 

Supongo que te gusta

Origin blog.csdn.net/piyangbo/article/details/126264097
Recomendado
Clasificación