You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio大黄蜂2021.1.1补丁3模拟器运行代码报错求助

解决Android Studio Bumblebee中com.android.application插件应用失败问题

错误详情

Build file 'C:\Users\ayush\AndroidStudioProjects\MyworkSpaceApp\app\build.gradle' line: 2

An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
> Could not create an instance of type com.android.build.gradle.internal.plugins.AppPlugin$ApplicationAndroidComponentsExtensionImplCompat.
> Could not generate a decorated class for type AppPlugin.ApplicationAndroidComponentsExtensionImplCompat.
> Cannot have abstract method AndroidComponentsExtension.registerSourceType().

可行解决方案

  • 匹配Gradle插件与Gradle版本
    Android Studio Bumblebee 2021.1.1 Patch 3对应Gradle插件版本为7.1.3,Gradle版本为7.2。修改项目根目录build.gradle:

    dependencies {
        classpath "com.android.tools.build:gradle:7.1.3"
    }
    

    同时修改gradle/wrapper/gradle-wrapper.properties:

    distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
    
  • 清理重建并同步项目
    依次执行:

    1. 菜单栏点击Build > Clean Project
    2. 点击Build > Rebuild Project
    3. 重启Android Studio,点击右上角Sync Project with Gradle Files
  • 排查第三方插件冲突
    暂时移除项目中的第三方Gradle插件(如Hilt、ARouter相关插件等),重新同步项目,确认是否由插件版本不兼容导致。

  • 删除Gradle缓存
    删除以下目录后重新同步:

    • Windows系统:C:\Users\<你的用户名>\.gradle\caches
    • 项目根目录下的.gradle文件夹

内容的提问来源于stack exchange,提问作者Ayush Shende

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 19:47:03