Adding Firebase Crashlytics to an Android app

Sigh. ok ;).

I’ll have a look tomorrow. Do you happen to have a simple test case project handy that I can use?

1 Like

I’ll dm you

1 Like

Done. l add the child elements from then new element to the exiting ones without any further checking for duplication. And any attribute set on the new element I set on the existing, potentially overwriting the existing value (while will potentially lead to different based on the order stuff is encountered).

We’ll have to play it by ear and see what else breaks.

existing

 <service
            android:name="com.google.firebase.components.ComponentDiscoveryService"
            android:exported="false" >
            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
        </service>

new

 <service
            android:name="com.google.firebase.components.ComponentDiscoveryService"
            android:directBootAware="true"
            android:exported="false"
            tools:targetApi="n" />

merged

<service
            android:name="com.google.firebase.components.ComponentDiscoveryService"
            android:exported="false" 
            android:directBootAware="true" 
            tools:targetApi="n">
            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
</service>

and then again:

 <service
            android:name="com.google.firebase.components.ComponentDiscoveryService"
            android:exported="false" 
            android:directBootAware="true" 
            tools:targetApi="n">
            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
1 Like

Hmm, actually after this, apt fails with

E:                   aapt: Error parsing XML: unbound prefix [/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.mattrobertson.WateryCrashTest-348420ADFB47D7518D7A89EA7ED986258A2A241C/Debug/Cooper-Android/AndroidManifest.xml (41)]

:frowning:

Fixed too…

1 Like

On a separate note, I just want to log this here for future purposes.

After looking into this more I’ve learned that the GoogleServicesTask does not actually add support for Firebase Crashlytics but simply for Firebase. The new Firebase Crashlytics does depend on Firebase, so this is still a necessary step, but it also requires a separate firebase-crashlytics Gradle plugin, which Google has not yet open-sourced :weary: There is an open Issue for it on the Firebase GitHub page, but no recent news.

If I get some time, I may look into attempting to reverse-engineer it based on what changes it makes to the final merged AndroidManifest.xml. But until then, this thread checks the “Firebase” box but not the “Crashlytics” box :slightly_frowning_face:

:frowning:

that’d be cool!

gotcha.

Great news here!

  1. As of .2523, Firebase Analytics is working. All that is needed is to add the google-services.json file to the project and add com.google.firebase:firebase-analytics as a gradle reference.
  2. Firebase Crashlytics can be easily configured to work as well. As of .2523, all that is needed is to add the following line to strings.xml (replacing {your app package} with your actual application package name.

<string name="com.crashlytics.android.build_id">{your app package}.firebase.build.id</string>

  1. If this is all that is needed (and it seems to be) it should be pretty straightforward to tie this into EBuild similar to the way the GoogleServicesTask works.
1 Like

that’s awesome!

it should be pretty straightforward to tie this into EBuild similar to the way the GoogleServicesTask works.

do you suggest any of this should be automated by EBuild (if so, tied to what)? or should these just be two steps a user has to take themselves to use Analyitcs?

It would be nice to have it automated since it’s a straightforward step that’s not well-documented by Google (Google’s solution is to add the Gradle task that automates this).

It probably makes most sense to add it as a distinct task since GoogleServices can be added without adding Crashlytics. There could be a FirebaseCrashlyticsTask that runs after the GoogleServicesTask completes. All the FirebaseCrashlyticsTask would do is generate a strings.xml with that id string resource I mentioned above, and add it as an intermediate to be merged into the final strings.xml.

As for when I runs, it should run if and only if firebase-crashlytics is added to the project. So either the FirebaseCrashlyticsTask could check for this as a run condition, or there could be a project-level setting. I think checking for the existence of the firebase-crashlytics library would be best, since any time the library is added, the task should be run.

The GoogleServices task is bound to having a GoogleServices object that gets processed, though. There’s no such thing as that for FirebaseCrashlytics. What should be try trigger, simple having a reference to com.google.firebase:firebase-analytics?

com.google.firebase:firebase-crashlytics but yes, that should be good.

1 Like

Thanks, logged as bugs://84496

Since currently nothing plot-processes strings.xml, this will me some jar refactoring for a (id say) corner-case and easily handled manually scenario, so this is logged as relatively low priority.

1 Like

bugs://E24252 was closed as fixed.