Firebase Analytics building error

 

If your exception looks similar to this:

stderr[
Error: [Temp/StagingArea/AndroidManifest-main.xml:39, /Users/dennieguy/Documents/Development/stanTestProject/Temp/StagingArea/android-libraries/firebase-common/AndroidManifest.xml:5] Trying to merge incompatible /manifest/application/provider[@name=com.google.firebase.provider.FirebaseInitProvider] element:
  <provider
--    @android:authorities="com.TEST.stantest.firebaseinitprovider"
  <provider
++    @android:authorities="${applicationId}.firebaseinitprovider"
Error: [Temp/StagingArea/AndroidManifest-main.xml:24, /Users/dennieguy/Documents/Development/stanTestProject/Temp/StagingArea/android-libraries/firebase-iid/AndroidManifest.xml:15] Trying to merge incompatible /manifest/application/receiver[@name=com.google.firebase.iid.FirebaseInstanceIdReceiver] element:
  <receiver
      @android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
      <intent-filter>
              @android:name="com.google.android.c2dm.intent.RECEIVE">
--        <action
--            @android:name="com.google.android.c2dm.intent.REGISTRATION">
--        </action>
  <receiver
      @android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
      <intent-filter>
              @android:name="com.google.android.c2dm.intent.RECEIVE">
++        <category
++            @android:name="${applicationId}">
++        </category>
]

That is the common problem with Official Firebase Analytics libraries.

In order to fix it you should to do next steps:

1. Open AndroidManifest.xml by path: Plugins/Android

2. Find receiver tag:

    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:permission="com.google.android.c2dm.permission.SEND" android:exported="true">
      <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="com.unionassets.android.plugin.preview" />
      </intent-filter>
    </receiver>

Find package name for our project -> com.unionassets.android.plugin.preview. It will be different for you. 

You should replace it with new one. Your receiver must looks like:

    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:permission="com.google.android.c2dm.permission.SEND" android:exported="true">
      <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="${applicationId}" />
      </intent-filter>
    </receiver>

So, as a result We have changed one line:

<category android:name="com.unionassets.android.plugin.preview" />

on

<category android:name="${applicationId}" />

3. Now you should find another line:

 <provider android:name="com.google.firebase.provider.FirebaseInitProvider" android:initOrder="100" android:exported="false" android:authorities="com.unionassets.android.plugin.preview.firebaseinitprovider"/>

Find package name for our project -> com.unionassets.android.plugin.preview. It will be different for you.

You should replace it with new one. Your provider must looks like:

 <provider android:name="com.google.firebase.provider.FirebaseInitProvider" android:initOrder="100" android:exported="false" android:authorities="${applicationId}.firebaseinitprovider"/>

So, as a result We have changed part of the line of provider tag:

com.unionassets.android.plugin.preview

on

${applicationId}

4. Save AndroidManifest.xml. Close it.

5. Now you should open another AndroidManifest.xml by path: Plugins/Android/AN_Res

6. Find application tag and remove everything from it.

7. This tag should looks like:

<application></application>

8. Save this AndroidManifest.xml. Close it.

9. In order to your build system understands symbol $ in line ${applicationId}, You should to set Gradle Build System and set Minify none for both option. Take a look at these screenshots please:

 

10. The final step, you should sign in your application with Keystore and alias.

Note: Keystore path shouldn't contains of punctuation marks like apostrof, question mark, etc.