firebaseunity-game-enginegoogle-cloud-firestoreadmob

‘”Default FirebaseApp failed to initialize because no default options were found” error and conflict between Admob and Firestore in Unity


When I installed Admob and Firestore packages, I was getting the error ‘property#android.adservices.AD_SERVICES_CONFIG@resource=@xml/gma_ad_services_config` in com.google.android.gms:play-services-measurement-api:22.1.2 collides with another value’ in the apk build process. As a result of my research, I added the following to the AndroidManifest.xml file to prevent collision:

<property
   android:name="android.adservices.AD_SERVICES_CONFIG’
   android:resource="@xml/gma_ad_services_config’
   tools:replace=‘android:resource’ />

I added the lines and got the apk build process without any problems. However, although there is no problem in displaying ads, I noticed that I could not use the Firestore service. In my checks with Android Logcat, I saw that the error ‘Default FirebaseApp failed to initialize because no default options were found.’ was received.

The content of unityLibrary\build.gradle is as follows:

 dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])

 // Android Resolver Dependencies Start

     implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12

     implementation 'com.google.android.gms:play-services-ads:23.5.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7

     implementation 'com.google.android.gms:play-services-base:18.5.0' // Assets/Firebase/Editor/AppDependencies.xml:17

     implementation 'com.google.android.ump:user-messaging-platform:3.1.0' // Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7

     implementation 'com.google.firebase:firebase-analytics:22.1.2' // Assets/Firebase/Editor/FirestoreDependencies.xml:15

     implementation 'com.google.firebase:firebase-app-unity:12.4.1' // Assets/Firebase/Editor/AppDependencies.xml:22

    implementation 'com.google.firebase:firebase-common:21.0.0' // Assets/Firebase/Editor/AppDependencies.xml:13

     implementation 'com.google.firebase:firebase-firestore:25.1.1' // Assets/Firebase/Editor/FirestoreDependencies.xml:13

    implementation 'com.google.firebase:firebase-firestore-unity:12.4.1' // Assets/Firebase/Editor/FirestoreDependencies.xml:20

 // Android Resolver Dependencies End

     implementation(name: 'googlemobileads-unity', ext:'aar')

     implementation project(':unityLibrary:GoogleMobileAdsPlugin.androidlib')

     implementation 'androidx.appcompat:appcompat:1.6.1'

    implementation 'androidx.core:core:1.9.0'

     implementation 'androidx.games:games-activity:3.0.5'

    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

     implementation 'androidx.games:games-frame-pacing:1.10.0'

 }

I would appreciate your help.


Solution

  • I solved the problem. I was using Unity version 6000.0.23f1. I switched to version 6000.0.27f1. During the apk build process

    property#android.adservices.AD_SERVICES_CONFIG@resource=@xml/gma_ad_services_config` in com.google.android.gms:play-services-measurement-api:22.1.2 collides with another value
    

    error was persisting. I added the following lines to Plugins/Android/AndroidManifest.xml file and Firestore and Admob worked smoothly:

    <manifest
        ...
    
        <application
            ...
    
            <property
                android:name="android.adservices.AD_SERVICES_CONFIG’
                android:resource="@xml/gma_ad_services_config’
                tools:replace=‘android:resource’ />
            
            ...
        </application>
    
        ...
    </manifest>
    

    In short, my problem was caused by Unity version 6000.0.23f1.