sarriaroman / FabricPlugin

Fabric.io plugin for Cordova or Phonegap
MIT License
198 stars 159 forks source link

Crashlytics was applied to a project without an Android plugin #120

Open raul-handpoint opened 6 years ago

raul-handpoint commented 6 years ago

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:

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 commented 6 years ago

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.

ElodieC commented 6 years ago

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

raul-handpoint commented 6 years ago

I am leaving this issue opened per @ElodieC request.

raul-handpoint commented 6 years ago

Looks like issue #119 is exactly the same.

comur commented 6 years ago

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

chancezeus commented 6 years ago

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()

814k31 commented 6 years ago

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

chancezeus commented 6 years ago

@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).

814k31 commented 6 years ago

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

viking2917 commented 6 years ago

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

chancezeus commented 6 years ago

@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

viking2917 commented 6 years ago

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

viking2917 commented 6 years ago

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

mnowak-umich commented 6 years ago

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!

viking2917 commented 6 years ago

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

chancezeus commented 6 years ago

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:

mnowak-umich commented 6 years ago

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 notifications@github.com Reply-To: sarriaroman/FabricPlugin reply@reply.github.com Date: Wednesday, February 7, 2018 at 6:28 PM To: sarriaroman/FabricPlugin FabricPlugin@noreply.github.com Cc: mnowak-umich mnowak@umich.edu, Mention mention@noreply.github.com 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 commented 6 years ago

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

kagde commented 5 years ago

@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