Pitfalls encountered when Unity uses Gradle packaging to connect to Firebase in the configuration file google-services.json

Pitfalls encountered when Unity uses Gradle packaging to connect to Firebase in the configuration file google-services.json

1. Google-services.json cannot be found when packaging unity

1. First introduce ''com.google.gms.google-services' at the top of mainTemplate.gradle
as shown below:
Insert image description here
2. Add a task to mainTemplate.gradle and copy the downloaded google-services.json to the root directory of the gradle project.

task copyJsonFile {
    copy {
        delete("google-services.json")
        from('F:/Git/Android/AndroidSdk/UnityProject/')
        into('./')
        include("google-services.json")
    }
}
preBuild.dependsOn copyJsonFile

As shown below:
Insert image description here

2. When packaging unity, no package name: 'com.unity3d.player'

Change the attribute value of package_name in your original file google-services.json to com.unity3d.player
as shown below:Insert image description here

Guess you like

Origin blog.csdn.net/qq_18924323/article/details/128077485