Android Question Firebase Invalid Project ID (SOLVED)

iCAB

Well-Known Member
Licensed User
Longtime User
Hi There

I am using the code below from a long time. I just came back to it after few months and I noticed that I am getting the error below
B4X:
(IllegalArgumentException) java.lang.IllegalArgumentException: Please set your project ID. A valid Firebase project ID is required to communicate with Firebase server APIs: It identifies your project with Google.

The error is caused by
B4X:
Dim cTokenID As String = fm.Token


The actual code is here
B4X:
Public Sub SubscribeToTopics2( lstTopics As List)

    If Not(fm_IsInitialized) Then
        Return
    End If

    Dim i As Int   
    
    For i = 0 To lstTopics.Size - 1
        fm.SubscribeToTopic(lstTopics.Get(i))
    Next
        
    'fm.SubscribeToTopic("general") 

#if B4A   
Try
    Dim cTokenID As String = fm.Token 'This line generates the error
    LogColor("Passed",Colors.Blue)
Catch
    LogColor("Crashed",Colors.Blue)
End Try
#end if
  
End Sub


I tried using the exact same package name and the exact same json file in a sample project, but I don't see the issue.

Does anyone know what would cause the above?

Thanks in advance.

iCAB
 

iCAB

Well-Known Member
Licensed User
Longtime User
I have the following entries in the manifest code.

B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)

What else should I be looking for?
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
I tried few backups from couple of months ago. These backups didn't have any issues at that time. Now I am facing the same issues.


Also, now the 2 projects have the same manifest file from b4A perspective.

Please advise.
 
Last edited:
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Erel, thanks for your reply.
Please note that I have done that multiple times. if you insist I'll do it again, but if the issue is the android SDK, why would one project execute the same line of code ok while the other doesn't?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Forcing your app to use Android 4 theme is a mistake (SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")).
2. targetSdkVersion should be 29.


I don't see the cause of this error in the manifest. Make some tests. Make a copy of the project and remove everything from the manifest editor except of the firebase + google play related lines.

I assume that you are using the latest version of B4A with the latest version of Android SDK + components (don't open B4A Sdk Manager at all).
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
I assume that you are using the latest version of B4A with the latest version of Android SDK + components (don't open B4A Sdk Manager at all).
Not opening the SDK manager at all is not an option at all. I have tried this several times, and every time something is missing.

Also as I mentioned before, the sample project that I built to simulate the issue has the exact same B4A manifest file now, but I don't see the problem
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
It would seem that the problem could be at the firebase end.


I would create a new package name in firebase , download the new google-services.json and use that one in the android app.
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
I would create a new package name in firebase , download the new google-services.json and use that one in the android app.
Thanks for your feedback:
1. I would be worried about changing the package name as the app is in production
2. The same package name works in a different project

What do you think?
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Yes, shouldn't change the package name of a production app :(

Did you try re-download the google-services.json from the appropriate firebase project?

I also had a problem once where the firebase file had been copied to both the main project directory and the files directory by mistake which caused some problems as well.
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Yes, I did redownload the .json file and I just double checked that the json file is located in the main project folder only.

Thanks for your help!
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Thanks everyone for your help.

The issue was this:
I had a readonly flag set on the "res" folder to prevent the compiler from overwriting the application icon (I believe this was an issue long time ago)

Deleting the "objects" folder resolved the issue

But I am still not sure why and how the problem started. I always had this flag on.

Problem solved!
 
Upvote 0
Top