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

求助:Ionic Cordova项目Gradle构建遇Crashlytics插件应用错误

Fixing "Crashlytics was applied to a project without an Android plugin" Error in Ionic Cordova

Hey there, I’ve run into this exact issue before with cordova-fabric-plugin—let’s break down how to fix it. The error is crystal clear: the io.fabric plugin is being loaded before the Android Gradle plugin (com.android.application), which Crashlytics depends on to function properly. Here’s what you can do to resolve this:

Step 1: Verify Gradle Plugin Order

First, head to your project’s platforms/android/build.gradle file. Look for the lines where plugins are applied. The correct order must be:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

If you see io.fabric listed before com.android.application, that’s the root cause. Move the io.fabric line below the Android plugin line and save the file.

Step 2: Reinstall the Cordova Fabric Plugin

Sometimes the plugin injects its Gradle scripts in the wrong order during installation. Try removing and re-adding the plugin to fix this automatically:

# Remove the plugin
cordova plugin remove cordova-fabric-plugin

# Reinstall it
cordova plugin add cordova-fabric-plugin

After reinstalling, double-check the build.gradle file to confirm the plugin order is now correct.

Step 3: Ensure Gradle & Android SDK Compatibility

Older Gradle versions might not handle plugin ordering correctly, or could be incompatible with the fabric plugin. Check your Gradle wrapper version in platforms/android/gradle/wrapper/gradle-wrapper.properties:

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

Make sure this version matches the requirements of your Android plugin (you can check the Android plugin version in build.gradle under dependencies for com.android.tools.build:gradle). If needed, update the Gradle version to a compatible one.

Step 4: Clean & Rebuild Your Project

After making any changes, clean your project to clear cached build files, then rebuild:

# Clean the Android project
ionic cordova clean android

# Rebuild
ionic cordova build android

That should resolve the plugin ordering issue and get your build working again. The key here is ensuring Crashlytics (via the fabric plugin) always loads after the Android plugin—Crashlytics needs Android’s build tools to be initialized first.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:53:18