FabricPlugin: Crashlytics was applied to a project without an Android plugin

I am working on a cordova app that uses cordova-fabric-plugin.

We are recently having this error when building the app with Gradle, and we are not able to identify the cause:

Failed to apply plugin [id 'io.fabric'] Error:(66, 0) Crashlytics was applied to a project without an Android plugin. Please make sure the Crashlytics plugin is applied after the appropriate Android plugin for your project.

Gradle build is generated from a package.json file which defines the dependencies of the project. Two of these dependencies are:

  • cordova-android: 7.0.0
  • cordova-fabric-plugin: ^1.1.10

This is the generated build.gradle file that causes the error:

build.gradle

Is this a bug in the plugin? Can someone help me here, please?

Thank you. Kind regards.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 4
  • Comments: 19

Most upvoted comments

I got this error:

Failed to fetch plugin https://github.com/chancezeus/FabricPlugin.git via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL. Failed to get absolute path to installed module (node:34859) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

– Mike Nowak Center for Health Communications Research šŸ“¬ North Campus Research Complex 2800 Plymouth Road, Building 16 The University of Michigan šŸ’»Ā http://chcr.umich.edu/


Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues

For those looking for a quick fix for now, I just created a quick fork with my fixes applied. I tested a quick build with android 7.0.0 and there seem to be no problems. The fix should remain backwards compatible and thus should be pullable as is without any issues. Pull request (#122) has been submitted but for now you can install my version using: [ionic] cordova plugin add https://github.com/chancezeus/FabricPlugin.git --variable FABRIC_API_KEY={YOUR API KEY} --variable FABRIC_API_SECRET={YOUR API SECRET}

Hope it helps those in need 😌

@viking2917 The edits have to be done in the plugins/… folder before adding the platform, otherwise the gradle change also has to be applied in the copy created by cordova inside the android platform folder

Fix for this issue:

in hooks/lib/utilities.js replace getBuildGradlePath function with:

function getBuildGradlePath() {
    var target = path.join("platforms", "android", "app", "build.gradle");
    if (fs.existsSync(target)) {
        return target;
    }

    return path.join("platforms", "android", "build.gradle");
};

This triggers a new error because in the src/android/build-extras.gradle the config.xml is referenced in the wrong location, fixing it by pointing to the correct folder makes it work but breaks backwards compatibility so if anyone knows a fix that maintains backwards compatibility please comment.

Simple (not-backwards compatible) fix: Replace def config = file("res/xml/config.xml").getText() with def config = file("src/main/res/xml/config.xml").getText()

@chancezeus OK that did it.

ionic cordova platform rm android
cordova plugin add cordova-fabric-plugin --variable FABRIC_API_KEY=<yourkey> --variable FABRIC_API_SECRET=<yourkey>
(your edits done to the files under the plugin folder per the above)
ionic cordova platform add android

And that did the trick. Thank you so much!

Hi, Did you find a solution for this ? I’m on cordova 8 and cannot downgrade. Thanks

Looks like issue #119 is exactly the same.

Looks like this is an incompatibility of the plugin with cordova-android platform 7.0.0.

After updating Android platform to version 6.4.0:

ionic cordova platform rm android
ionic cordova platform add android@6.4.0

Generated Gradle script builds OK.