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

如何修复Ionic构建Android时的‘Could not find android-maven-gradle-plugin.jar’错误?

Fixing "Could not find android-maven-gradle-plugin.jar" in Ionic Android Builds

Hey there, let’s tackle that frustrating error you’re seeing when building your Ionic Android project. I’ve helped a few developers work through this exact issue, and these are the most effective solutions to get your build running smoothly again:

1. Verify and Update Gradle Dependencies & Repositories

First, double-check your project’s Gradle configuration to ensure the plugin is being pulled correctly:

  • Navigate to your Ionic project’s root folder, open android/build.gradle, and locate the buildscript block.
  • In the dependencies section, confirm you have a valid reference to the plugin, like:
    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    
    If you’re using an older version, try updating to 2.1 (it’s widely compatible with most Ionic/Cordova setups).
  • Make sure the buildscript > repositories section includes mavenCentral() or google()—this is where the plugin is hosted, so missing these will prevent Gradle from finding the jar.

2. Clear Gradle’s Cache

Corrupted or outdated cache files often cause dependency lookup failures. Here’s how to fix it:

  • Run this command in your project’s android directory to clean and refresh dependencies:
    # macOS/Linux
    ./gradlew clean build --refresh-dependencies
    
    # Windows
    gradlew.bat clean build --refresh-dependencies
    
  • If that doesn’t work, manually delete Gradle’s cache directory:
    • Windows: C:\Users\<YourUsername>\.gradle\caches
    • macOS/Linux: ~/.gradle/caches
      After deleting, restart your IDE and try building again.

3. Check for Plugin Compatibility Issues

Old or poorly maintained Cordova plugins might be pulling in conflicting versions of the maven plugin:

  • Run ionic cordova plugin list to see all installed plugins. Look for any plugins that haven’t been updated in a year or more—these are prime suspects.
  • Update suspicious plugins with:
    ionic cordova plugin update <PluginName>
    
    If updating doesn’t help, try uninstalling and re-installing the plugin to get the latest compatible version.

4. Downgrade Gradle to a Compatible Version

Newer Gradle versions can sometimes break compatibility with older plugins like android-maven-gradle-plugin. Try rolling back to a stable, compatible version:

  • Open android/gradle/wrapper/gradle-wrapper.properties and modify the distributionUrl line to use a compatible Gradle version, e.g.:
    distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
    
    This version works reliably with the 2.1 release of the maven plugin.
  • Save the file and re-run your build command.

Bonus Tip

If none of the above works, create a fresh blank Ionic project and attempt to build it for Android. If the fresh build works, the issue is likely with your original project’s configuration—you can then gradually migrate your code, assets, and plugins to the new project to isolate the problem.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 06:45:12