FabricPlugin icon indicating copy to clipboard operation
FabricPlugin copied to clipboard

Crashlytics was applied to a project without an Android plugin

Open raul-handpoint opened this issue 7 years ago • 19 comments

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.

raul-handpoint avatar Jan 12 '18 18:01 raul-handpoint

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 [email protected]

Generated Gradle script builds OK.

raul-handpoint avatar Jan 15 '18 10:01 raul-handpoint

For me, you can leave this issue opened. It will need to work with newest version of cordova (cordova 8).

ElodieC avatar Jan 15 '18 13:01 ElodieC

I am leaving this issue opened per @ElodieC request.

raul-handpoint avatar Jan 15 '18 18:01 raul-handpoint

Looks like issue #119 is exactly the same.

raul-handpoint avatar Jan 15 '18 18:01 raul-handpoint

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

comur avatar Jan 22 '18 12:01 comur

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 avatar Jan 25 '18 17:01 chancezeus

@chancezeus I tried your solution which built fine, however I would get an error message Failed to send analytics. Did you manage to get it working all the way?

814k31 avatar Jan 29 '18 07:01 814k31

@814k31 I just checked and for me both sending a custom event and a crash report both succeed so I think this error is either not related to this specific plugin or it is configured incorrectly (wrong key/secret for example).

chancezeus avatar Jan 29 '18 09:01 chancezeus

Interesting I've had it working fine with cordova-android 6.4 for ages so I may sit on it for a little before trying again

Thanks

814k31 avatar Jan 30 '18 00:01 814k31

have the same problem and the suggested edits from @chancezeus don't seem to work for me.

viking2917 avatar Feb 06 '18 19:02 viking2917

@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

chancezeus avatar Feb 06 '18 19:02 chancezeus

aha. thank you @chancezeus . Let me give that a go.

viking2917 avatar Feb 06 '18 20:02 viking2917

@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!

viking2917 avatar Feb 06 '18 23:02 viking2917

I still seem to be getting this error, even with the steps above.

A problem occurred evaluating root project 'android'.

Failed to apply plugin [id 'io.fabric'] 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.

I assume the changes to hooks/lib/utilities.js are in plugins/cordova-fabric-plugin/hooks/lib/utilities.js?

Is this error message referring to a Cordova plugin or a Fabric plugin or something else. Thanks!

mnowak-umich avatar Feb 07 '18 22:02 mnowak-umich

@mnowak-umich The error is in regard to the Cordova Fabric Plugin (the plugin whose github page we are on), I don't think I have any other plugins that are related to this issue.

I took the following steps. removed the android platform. per the above, edited the two files

plugins/cordova-fabric-plugin/hooks/lib/utilities.js plugins/cordova-fabric-plugin/src/android/build-extras.gradle

the added the android platform back, and then it worked for me. Hope that helps.

viking2917 avatar Feb 07 '18 22:02 viking2917

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 :relieved:

chancezeus avatar Feb 07 '18 23:02 chancezeus

Thanks I will give it a try today!

-- Mike Nowak Center for Health Communications Research 📬 North Campus Research Complex 2800 Plymouth Road, Building 16 The University of Michigan 💻 http://chcr.umich.eduhttp://chcr.umich.edu/ From: Mark van Beek [email protected] Reply-To: sarriaroman/FabricPlugin [email protected] Date: Wednesday, February 7, 2018 at 6:28 PM To: sarriaroman/FabricPlugin [email protected] Cc: mnowak-umich [email protected], Mention [email protected] Subject: Re: [sarriaroman/FabricPlugin] Crashlytics was applied to a project without an Android plugin (#120)

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 (#122https://github.com/sarriaroman/FabricPlugin/pull/122) has been submitted but for now you can install my version using: cordova plugin add https://github.com/chancezeus/FabricPlugin.git

Hope it helps those in need 😌

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/sarriaroman/FabricPlugin/issues/120#issuecomment-363947086, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABge_Io7qldBHdj_CzLSvcNx53EN83vzks5tSjF-gaJpZM4RctVC.


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

mnowak-umich avatar Feb 08 '18 13:02 mnowak-umich

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

mnowak-umich avatar Feb 08 '18 14:02 mnowak-umich

@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!

Yes its working thank you so much

kagde avatar Dec 21 '18 09:12 kagde