Android Question Compiler warnings

davemorris

Active Member
Licensed User
Longtime User
Hi, Guys
I am having a purge and decided to address all the Compiler warnings for my App. But I am left with
Library 'FirebaseAnalytics' is not used. (warning #32)

My App uses Push notifications, so I assume this library is required (but the code will compile without it - not sure if it runs correctly as the GPS is rarely used and difficult to test).

Obviously, within the code I have used the following to remove warnings - usually left in for future work
Ignore to remove a warning:
Dim unusedVariable as int 'Ignore - i.e. leave maybe used later!

Question: how do we remove these library warnings?

Kind regards
Dave
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

davemorris

Active Member
Licensed User
Longtime User
Hi Donfred
Thanks for the input, but using #IgnoreWarning will not provide a satisfactory result i.e.
Remove un-used library warning:
#IgnoreWarning  32 '
As it will remove ALL un-used library compiler warnings.

I found a workaround by including this code somewhere in the project.
Work around for Warning #32 (in my case within a class).:
Sub Class_Global
    Private fa as FirebaseAnalytics
    '|
    'More code as required.
End Sub

Public Sub Initialize 
    fa.Initialize ' Inserted to remove compiler warning.
    '|
    'More code as required.
End Sub

I am not great on how B4A works under the hood, but my C# experience says this just creates a new instance of FirebaseAnalytics (only if the class is used) and the garbage collector will remove it when the instance goes out of scope.

So I don't see any harm, please advise of otherwise - or obviously if someone has a more elegant solution.

Kind regards
Dave
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Probably better. If you put it in Globals it won't go out of scope and be garbage collected - it will as a local variable.
B4X:
Public Sub Initialize
   Private fa as FirebaseAnalytic
    fa.Initialize ' Inserted to remove compiler warning.
    '|
    'More code as required.
End Sub
 
Upvote 0
Top