ReallySmallSoftware / cordova-plugin-firebase-crashlytics

Google Firebase Crashlytics Cordova plugin
Other
32 stars 80 forks source link

iOS run / Android builds do not work #21

Closed DCGoD closed 4 years ago

DCGoD commented 5 years ago

Expected Behavior

iOS or Android to function. Neither do.

Actual Behavior

iOS builds, displays errors the plugin could not be installed when actually ran. Android doesn't build with the errors displayed in other reports such as here.

Steps to Reproduce the Problem

Follow the instructions for install on this page. Run your iOS app and you'll see log errors stating the plugin could not start. Build / Run android and you'll see an error about the API key missing.

Specifications

surya-alive commented 5 years ago

I have same issue on android. Install cordova-support-google-services as well then it works.

DCGoD commented 5 years ago

Thanks for the response. That did indeed get Fabric loaded but now I get another error in iOS preventing the app to actually run.

*** Terminating app due to uncaught exception 'FABException', reason: '[Fabric] Value of Info.plist key "Fabric" must be a NSDictionary.'
*** First throw call stack:
DCGoD commented 5 years ago

The plugin now installs on ionic-native 5.6.0 but I still receive an error about initializing the plugin. I've tried manually using a Cordova import and also the standard installation method. Neither work yet. Could someone please share what they did to actually have this work?

Native: tried calling FirebaseCrashlytics.logException, but the FirebaseCrashlytics plugin is not installed.
Install the FirebaseCrashlytics plugin: 'ionic cordova plugin add cordova-plugin-firebase-crashlytics'
amymarsh4work commented 5 years ago

@MarkAMcCorkle I was not able to use this plugin in my app, but my main problem was that I ran into compatibility issues over cordova-support-google-services because we have an older version of phonegap-plugin-push.

I wasn't able to get cordova-plugin-firebase-crash to work either.

For what it's worth, I went back to what worked in our Ionic 3 app. Now, I'm running Ionic 4 and have had success with Firebase Crashlytics by using: Crashlytics found in @ionic-native/fabric with the cordova-fabric-plugin.

ionic-native/fabric I was thrown off by the Ionic 4 Native docs and assumed Crashlytics wasn't included in Ionic 4. Not true. It's under 'Answers', (sort of). See: https://ionicframework.com/docs/native/fabric - This is confusing because their docs only discuss 'Answers'. It could be a documentation issue.

If you look at the V3 docs, you'll see what I was looking for: https://ionicframework.com/docs/v3/native/crashlytics/

Their @ionic-native/fabric wrapper STILL HAS Crashlytics and Answers in the source code. See: https://github.com/ionic-team/ionic-native/blob/master/src/%40ionic-native/plugins/fabric/index.ts

cordova-fabric-plugin The actual plugin docs provide a good description of what's going on and how to get set up: https://www.npmjs.com/package/cordova-fabric-plugin Note: For iOS, we also had to do the steps 'Add a Run Script Build Phase' described here: https://fabric.io/kits/ios/crashlytics/install

I saw that you were having trouble, because I was too.

Good Luck!

JoJo-Bear commented 4 years ago

I have been able to get it work. In order to do this I needed some additional coding found over some other tutorials. versions:

node: 12.13.1
Ionic:

   Ionic CLI                     : 5.4.9 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.11.5
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.1.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0, ios 5.1.0
   Cordova Plugins   : cordova-plugin-ionic 5.4.5, cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 16 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.2.9 

System:

   Android SDK Tools : 26.1.1 (/Users/joey/Library/Android/sdk)
   ios-deploy        : 1.9.4
   ios-sim           : 8.0.2
   NodeJS            : v12.13.1 (/usr/local/bin/node)
   npm               : 6.13.1
   OS                : macOS Catalina
   Xcode             : Xcode 11.2.1 Build version 11B500

used dependencies

    "@ionic-native/firebase-crashlytics": "^5.17.1",
    "cordova-plugin-firebase-crashlytics": "^0.1.0",
    "cordova-support-google-services": "^1.3.2",

For android i needed to install the cordova-support-google-services and the firebase plugins itself

npm install cordova-support-google-services
npm install cordova-plugin-firebase-crashlytics --variable ANDROID_FIREBASE_CORE_VERSION=16.0.0
npm install @ionic-native/firebase-crashlytics

inside the config.xml make sure to add : xmlns:android="http://schemas.android.com/apk/res/android

<widget id="com.company.appname" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">

and set the resource file (the src is relative from the root of your app directive, the target is picked up and set to be found by the cordova-support-google-services plugin)

<platform name="android">
        <resource-file src="resources/google-services.json" target="app/google-services.json" />

For iOS it was a different story. It seems to me that the plugin is not complete and I needed to add a bit of code to the native file. First adding the pods to your project my podfile:

# DO NOT MODIFY -- auto-generated by Apache Cordova
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!
target '[App name]' do
    project '[App name].xcodeproj'
    pod 'Fabric', '~> 1.10.2'
    pod 'Crashlytics', '~> 3.14.0'

    # (Recommended) Pod for Google Analytics
    pod 'Firebase/Analytics'
end

The additional coding used inside iOS is placed in the AppDelegate.m the added lines are @import Firebase; and [FIRApp configure];

#import "AppDelegate.h"
#import "MainViewController.h"
@import Firebase;

@implementation AppDelegate

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    self.viewController = [[MainViewController alloc] init];
    [FIRApp configure];
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end

and also set the resource for iOS

 <platform name="ios">
        <resource-file src="GoogleService-Info.plist" />

app.component.ts:

import { FirebaseCrashlytics } from '@ionic-native/firebase-crashlytics/ngx';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.scss'],
  providers: [FirebaseCrashlytics]
})

inside constructor
private firebaseCrashlytics: FirebaseCrashlytics

const crashlytics = this.firebaseCrashlytics.initialise();

I really hope they add the changes that were needed to the AppDelegate.m inside the plugin since it will be a pain in the ass if we need te remove the iOS platform and install it again.

ReallySmallSoftware commented 4 years ago

This should be fixed soon. Thank you for your efforts.

jamespsterling commented 4 years ago

@ReallySmallSoftware any ETA on resolution? I'm struggling with getting this to load using all the methods I can find.

Ionic:

   Ionic CLI                     : 5.4.13 (/Users/***/.nvm/versions/node/v11.6.0/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.11.7
   @angular-devkit/build-angular : 0.803.21
   @angular-devkit/schematics    : 8.3.21
   @angular/cli                  : 8.3.21
   @ionic/angular-toolkit        : 2.1.1

Capacitor:

   Capacitor CLI   : not installed
   @capacitor/core : not installed

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0, browser 6.0.0, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 21 other plugins)

Utility:

   cordova-res                          : 0.8.1
   native-run (update available: 0.3.0) : 0.2.8

System:

   Android SDK Tools : 26.1.1 (/Users/***/Library/Android/sdk)
   ios-deploy        : 1.9.4
   ios-sim           : 8.0.2
   NodeJS            : v11.6.0 (/Users/***/.nvm/versions/node/v11.6.0/bin/node)
   npm               : 6.13.1
   OS                : macOS Catalina
   Xcode             : Xcode 11.3 Build version 11C29
ReallySmallSoftware commented 4 years ago

I have published a new release as it was being asked for, but I haven't had time to test properly