Android Question Crashlytics How To Set Custom Key

Tommaso

Member
Licensed User
Longtime User
Hi all,
I've upgrade b4a and firebase to the newer version to continue to receive crashlytics from my application even after 15 november 2020.
I continue to receive crashlytics fine but without custom key. (Custom Key where set by a Crashlytics module that use fabric)

Crashlytics Module:
Sub Class_Globals
    Private CL As JavaObject
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize (context As JavaObject)
#if Release
    Dim fabric As JavaObject
    CL.InitializeNewInstance("com.crashlytics.android.Crashlytics", Null)
    Dim kits As JavaObject
    kits.InitializeArray("io.fabric.sdk.android.Kit", Array(CL))
    fabric = fabric.InitializeNewInstance("io.fabric.sdk.android.Fabric.Builder", Array(context)) _
        .RunMethodJo("kits", Array(kits)) _
        .RunMethod("build", Null)

    Dim StaticFabric As JavaObject
    StaticFabric.InitializeStatic("io.fabric.sdk.android.Fabric").RunMethod("with", Array(fabric))
#end if
End Sub
Public Sub SetKey(Key As String, Value As String)
#if Release
    CL.RunMethod("setString", Array(Key, Value))
#end if
End Sub
Public Sub CLog(msg As String)
#If Release
    CL.RunMethod("log", Array(msg))
#else
    Log(msg)
#End If
End Sub

Someone has any suggestion on how to set CustomKey with newer version?
Thanks in advance
Tommaso
 

Tommaso

Member
Licensed User
Longtime User
Thanks Erel (but not work on b4a).
If someone else need to, I've solved like This:

B4X:
Private Sub GetCrashlytics As JavaObject
#if Release   
    Dim jo As JavaObject
    jo = jo.InitializeStatic("com.google.firebase.crashlytics.FirebaseCrashlytics").RunMethod("getInstance", Null)
    Return jo
#end if
End Sub
Public Sub SetKey(Key As String, Value As String)
#if Release
    GetCrashlytics.RunMethod("setCustomKey", Array(Key, Value))
#end if
End Sub
 
Upvote 0
Top