当前位置:   article > 正文

AS使用Gradle 7.2新建项目,编译失败_could not create an instance of type com.android.b

could not create an instance of type com.android.build.api.variant.impl.appl

使用最新版本的 Android Studio Bumblebee 新建 Empty Compose Activity时,编译报错:
使用的版本信息:

  • Android Studio Bumblebee
  • Gradle :7.2
  • Kotlin :1.5.21
  • Java SDK: 11

报错信息:

Could not initialize class com.android.build.gradle.internal.dsl.decorator.AndroidPluginDslDecoratorKt
  • 1

默认生成的文件:

build.gradle
在这里插入图片描述
settings.gradle:
在这里插入图片描述

修改后的:

build.gradle :

buildscript {
    ext {
        compose_version = '1.0.1'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

settings.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven {
            allowInsecureProtocol = true //添加关键字
            url "http://nexus.test.com/content/groups/android-common/"
        }
    }
}
rootProject.name = "ComposeTest"
include ':app'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

参考:

AS升级到gradle 7.0时遇到的若干问题

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/317487
推荐阅读
相关标签
  

闽ICP备14008679号