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

Cordova Android应用集成Gradle插件报错:插件未找到

解决Cordova Android端集成Firebase Distribution Gradle插件提示“未找到”的问题

问题分析

你遇到的UnknownPluginException通常是因为插件依赖加载时机不对、Gradle版本不兼容,或者仓库配置冗余导致的。以下是针对性的解决步骤:

1. 检查并升级Gradle版本

Firebase App Distribution 3.1.1要求Gradle版本至少为7.0。打开项目根目录下的gradle/wrapper/gradle-wrapper.properties,确认distributionUrl指向的Gradle版本符合要求:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip

如果版本过低,替换为上述链接或更高兼容版本。

2. 修改build-extras.gradle配置

原配置中插件应用时机不正确,且包含冗余仓库。替换为以下配置:

// build-extras.gradle
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.14'
        classpath 'com.google.firebase:firebase-appdistribution-gradle:3.1.1'
    }
}

// 针对Cordova的app模块配置插件
project(':app').afterEvaluate {
    apply plugin: 'com.google.gms.google-services'
    apply plugin: 'com.google.firebase.appdistribution'

    // 可选:添加Firebase Distribution的自定义配置
    firebaseAppDistribution {
        releaseNotesFile = file("release-notes.txt")
        groups = "internal-testers"
    }
}
  • 移除了jitpack.io、jcenter等非必需仓库,google()和mavenCentral()已包含插件所需的依赖源
  • 通过project(':app').afterEvaluate确保插件在app模块的配置加载完成后再应用,避免依赖未就绪的问题

3. 清理缓存并重新构建

执行以下命令清理旧缓存并重新构建项目:

cordova clean android
cordova build android

4. 确认Google Services配置文件

确保google-services.json已放置在platforms/android/app/目录下,这是Google Services插件正常工作的必要条件。

内容的提问来源于stack exchange,提问作者Moti Bartov

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.11 07:01:16