[Bug] INVALID_APP_ID error on Android
What is your question?
I'm troubleshooting what is likely a configuration error on my end, but I'm having trouble narrowing down the problem due to a vague error message.
Our build fails to login with the error An internal error has occurred. [ INVALID_APP_ID ]. Frustratingly this is only occurring when the game is built in our production pipeline, so I don't have a full call stack.
I can't find any documentation that specifies what app id the error is referring to (e.g. is it the mobile bundle id, the Firebase app id, or something else) other than this page which simply has INVALID_APP_ID's string value. This page has a list of helpful descriptions of exceptions, but I'm not sure which one this error maps to, if any.
Can someone provide some additional info on why the INVALID_APP_ID error occurs, and what might be some things to look into?
Firebase Unity SDK Version
11.7.0
Unity editor version
2022.3.10
Installation Method
.unitypackage
Problematic Firebase Component(s)
Authentication
Other Firebase Component(s) in use
Authentication
Additional SDKs you are using
No response
Targeted Platform(s)
Android
Unity editor platform
Windows
Scripting Runtime
IL2CPP
Release Distribution Type
Pre-built SDK from https://firebase.google.com/download/unity
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Hey @SHiLLySiT, thanks for reaching out. So far, I'm not experiencing any issues with running our quickstart Auth in the Unity Editor, and in an Android Emulator with either custom keystore or debug keystore. That said, could you answer a few questions below just as a sanity check:
- Which login provider are you having this issue? Is Firebase Auth working for other login providers?
- Have you enabled the login providers you're currently using in the Firebase Console?
- Lastly, have you checked if your Firebase project's
client_idandproject_idis correctly indicated in your Android appgoogle-services.json? If not, could you try replacing this with the correct json file and see if that helps.
Let me know if these help. Thanks!
Hi @argzdev, thanks for the reply!
To clarify, I don't think this is a problem on your end. Our project has a production and development Firebase project, and the development one had been working just fine. I think I've just missed something when flipping it over to production, but I'm just having trouble figure out what because the error isn't specific enough about the issue.
- We're using Microsoft, but we also have Google enabled because of this other issue. However we aren't actually using Google, so I cant speak to if other login providers are working or not.
- Yup!
- I've been thinking the problem was with the
google-services.jsonbut I've replaced it several times now and git hasn't actually shown any difference in the files. Unless somehow the Firebase Console isn't spitting out the right file?
Let me know if you have any other ideas!
EDIT: We also support WebGL and iOS, both of which are working with the production Firebase project, so I think its something specific to the Android. I'm not sure if it matters, but I had deleted a few previous Android apps from the console as we had some miscommunication on what the bundle id was. However I've double checked that the bundle id for the active app is the correct one.
I pulled the ADB logs from a development build, stack trace wasn't super helpful:
05-08 12:37:32.486 10927 10948 E Unity : One or more errors occurred. (An internal error has occurred. [ INVALID_APP_ID ])
05-08 12:37:32.486 10927 10948 E Unity : #0 0x73d6b1d868 (libunity.so) GetStacktrace(int) 0x44
05-08 12:37:32.486 10927 10948 E Unity : #1 0x73d705927c (libunity.so) DebugStringToFile(DebugStringToFileData const&) 0x234
05-08 12:37:32.486 10927 10948 E Unity : #2 0x73d66d0720 (libunity.so) DebugLogHandler::Internal_Log(LogType, LogOption, core::basic_string<char, core::StringStorageDefault<char> >, Object*) 0x9c
05-08 12:37:32.486 10927 10948 E Unity : #3 0x73d66d060c (libunity.so) DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*) 0x15c
05-08 12:37:32.486 10927 10948 E Unity : #4 0x73d4512304 (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #5 0x73d52f5e44 (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #6 0x73d520c27c (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #7 0x73d5305718 (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #8 0x73d5301fe8 (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #9 0x73d4b9be9c (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #10 0x73d4bd8a58 (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #11 0x73d44f766c (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #12 0x73d52f5e44 (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #13 0x73d520c27c (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #14 0x73d5305718 (libil2cpp.so) ? 0x0
05-08 12:37:32.486 10927 10948 E Unity : #15 0x73d5301fe8 (libil2cpp.so
But there was this system log:
FirebaseAuth: [GetAuthDomainTask] Error getting project config. Failed with INVALID_APP_ID 400
I'm still not quite sure what the issue is, but seems more likely its related to the google-services.json? The odd bit is that a local build works fine, so there's something going wrong when building headless.
Okay turns out that this is a bug 😕 I'd change the tag on this but looks like I don't have permissions to.
When integrating Firebase initially into our project, I made a local build with the configs for the development project and checked in the auto-generated file Assets\Plugins\Android\FirebaseApp.androidlib\res\values\google-services.xml along with all the other auto-generated files in the Assets\Plugins\Android. While this file is regenerated for local builds, it is not regenerated when running Unity headless.
My work around for now was just to manually check in the updated google-services.xml after making a local build with our configs for the production project. However IMO, Firebase should generate the same files when running headless or not.
Also related: I've been perplexed that there isn't guidance on what files can be ignored. I initially assumed all auto generated files could be ignored, which seemed to be supported by this comment. However, after running into other issues, I ended up checking in all files. Still not clear if this is what's intended or not, so would be awesome to have some official documentation on that.
Hey @SHiLLySiT, I must say this is an impressive investigation. Thanks for sharing your thoughts and the outcome of the investigation. This has been very insightful. Can you explain more about your usage of Unity Headless?
Correct me if I'm wrong, from my understanding, you have a production pipeline that whenever files are checked-in, it will automatically build, generate, and run a unity headless server. Which in this case, does not re-generate the google-services.xml?
As for the documentations, we'll try and work something out, I'll have to bring it up to our engineers for discussion.
@argzdev No problem!
When referring to running Unity headless, I was referring to running Unity via command line without the GUI. We specifically use the -executeMethod parameter to execute a method in our project which eventually just calls BuildPipeline.BuildPlayer().
I was trying to get you a simple project that reproduces the issue, however I can't seem to cut down the project enough to git past Github's file size limit 😕
However it was simple to setup:
- Create a new project with Unity 2022.3.10. Not sure if the version is important, but this is the one my project is using.
- Add FirebaseAuth 11.7.0. Again not sure if version is important, but this is the one my project is using.
- Download
google-services.jsonfrom a Firebase project and add to root ofAssets/. - Make an Android build.
- Observe that
Assets\Plugins\Android\FirebaseApp.androidlib\res\values\google-services.xmlis automatically created. - Either:
- Modify
google-services.xmlby hand to use different values than what exist ingoogle-services.json. - Replace
google-services.jsonwith one from another Firebase project.
- Modify
- Make another Android build.
- ----> Observe that
Assets\Plugins\Android\FirebaseApp.androidlib\res\values\google-services.xmlis not updated.
Important note: this behaves a slightly differently than what I described in my previous comment. Once the file Assets\Plugins\Android\FirebaseApp.androidlib\res\values\google-services.xml is generated, it is never updated again regardless if I make a manual build, running Unity via command line, or manually invoking BuildPipeline.BuildPlayer().
Hey @SHiLLySiT, thanks for the extra information. We really appreciate it! I was able to reproduce the behavior by testing a bunch of scenarios.
Scenario 1
- delete
google-services.json - add new
google-services.json - the
google-services.xmldoes not change - incorrect
Scenario 2
- update
google-services.jsonmanually google-services.xmldoes not change - incorrect
Scenario 3
- delete
google-services.json - delete
google-services.xml - add new
google-services.json - new
google-services.xmlis created - correct
Scenario 4
- delete
google-services.json - change platform to macOS, then back to Android
google-services.xmlis updated - correct
I'll go ahead and inform our engineering team to see what we can do here. Thanks!
I ran into this same problem on another project. This time with Firebase 12.1.0 and Unity 2022.3.36.