Hi All, I tried to implement capacitor community firebase crashlytics URL: https://github.com/capacitor-community/firebase-crashlytics
All steps followed as mentioned in README.md.
Here are my package.json
{
“name”: “app-name”,
“version”: “0.0.1”,
“private”: true,
“dependencies”: {
“@apollo/client”: “^3.1.2”,
“@capacitor-community/firebase-crashlytics”: “^0.3.0”,
…
},
…
}
uses in App.tsx
import { Plugins, DeviceInfo } from '@capacitor/core';
const { FirebaseCrashlytics, Device } = Plugins;
Device.getInfo()
.then((info: DeviceInfo) => {
if (info && info.platform && info.platform === 'android') {
FirebaseCrashlytics.crash({
message: 'This is a crash message',
});
}
});
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
}
}
apply from: "variables.gradle"
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android/app/build.gradle(last lines)
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
apply plugin: 'com.google.firebase.crashlytics'
MainActivity.java
package com.xxxx.xxx;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import com.getcapacitor.community.firebasecrashlytics.FirebaseCrashlytics;
import java.util.ArrayList;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(FirebaseCrashlytics.class);
}});
}
}
and google-services.json files confirmed placed in android/app
Result: App has stopped.
Expected: Working correctly as in there doc.