Jump to content
alejandro.sawers

Android 5 and Firebase support

Recommended Posts

Even though Delphi 12.x officially only supports Android 10+ devices as targets its actually possible to compile for lower Android versions with some tweaks on the NDK and the app Manifest. So far, so good it works as expected, but seems like there is an incompatibility when trying to add Firebase Messaging support and running it on an Android 5 device (i.e. API level 21, the lowest supported so far) :

java.lang.NoSuchMethodError: No virtual method detectResourceMismatches()Landroid/os/StrictMode$ThreadPolicy$Builder;
...
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:264)
at com.embarcadero.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:67)

Effectively detectResourceMismatches() was introduced later, on API level 23, so this explains the crash at app startup on Firebase initialization. Now what puzzles me is while Firebase docs claim to offer support to Android versions as low as API level 19 (4.4), Firebase on Delphi calls an API level 23 method on initialization. By the way the same docs also say that "some products might have stricter requirements", so to be sure I checked the Release Notes to see if Messaging requires a higher API level to run, but apparently API level 19 is OK for the Firebase libraries included with Delphi 12.2:

 

image.png.37f51ad22cee5996426db816115f69b9.png

 

For now I'm disabling automatic Firebase initialization for Android 5 devices to avoid the startup crash (using the tools:node method didn't work, removing the <%provider%> tag from the Manifest template did). Hope a workaround (maybe downgrading some Firebase dependencies) is found before having to drop the Lollipop 🍭.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×