Bug 53209 - Firebase Cloud Messaging (Xamarin.Firebase.Messaging 42.1001.0) fails to update AndroidManifest.xml correctly
Summary: Firebase Cloud Messaging (Xamarin.Firebase.Messaging 42.1001.0) fails to upda...
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2017-03-09 22:49 UTC by James Moore
Modified: 2017-03-16 22:39 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description James Moore 2017-03-09 22:49:49 UTC
Using Xamarin.Firebase.Messaging 42.1001.0, the build process fails to merge a bunch of XML from the relevant libraries.  If you pull FCM into an Android Studio project, you end up with these xml elements, and I've added some notes about what Xamarin isn't including.

There's some doc about what you need to add by hand, but it's incomplete, and the build process really does have to do this for you.

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android">

    <!--Xamarin.Firebase.Iid/library_project_imports/AndroidManifest.xml-->
    <uses-permission
        android:name="android.permission.WAKE_LOCK" />

    <!--Xamarin.Firebase.Iid/library_project_imports/AndroidManifest.xml-->
    <uses-permission
        android:name="com.google.android.c2dm.permission.RECEIVE" />

    <!--Xamarin.Firebase.Iid/library_project_imports/AndroidManifest.xml declares a new permission for your app using -->
    <!-- <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature"/> -->
    <!--however, Xamarin does NOT insert this into the final AndroidManifest.xml file-->
    <permission
        android:name="example.com.fcmproject.permission.C2D_MESSAGE"
        android:protectionLevel="0x2" />

    <!--and then it uses that permission-->
    <uses-permission
        android:name="example.com.fcmproject.permission.C2D_MESSAGE" />

    <application>
        <!--normal Firebase service definition, added by hand by the user-->
        <service
            android:name="example.com.fcmproject.MyFirebaseMessagingService">

            <intent-filter>

                <action
                    android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <!--Added by Android tooling-->
        <!--In Xamarin, added in Xamarin.Firebase.Messaging/library_project_imports/AndroidManifest.xml-->
        <service
            android:name="com.google.firebase.messaging.FirebaseMessagingService"
            android:exported="true">

            <intent-filter
                android:priority="-500">

                <action
                    android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <!--Xamarin.Firebase.Iid/library_project_imports/AndroidManifest.xml-->
        <!--Xamarin build doesn't include this-->
        <!-- https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-fcm/#backnotif
        does tell you to add it by hand-->
        <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="example.com.fcmproject" />
            </intent-filter>
        </receiver>

        <!--Xamarin.Firebase.Iid/library_project_imports/AndroidManifest.xml-->
        <!--Xamarin build doesn't include this-->
        <receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
            android:exported="false" />

        <!--Xamarin.Firebase.Iid/library_project_imports/AndroidManifest.xml-->
        <!--Xamarin build doesn't include this-->
        <service
            android:name="com.google.firebase.iid.FirebaseInstanceIdService"
            android:exported="true">

            <intent-filter
                android:priority="-500">

                <action
                    android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <!--Xamarin.Firebase.Common/library_project_imports/AndroidManifest.xml-->
        <provider
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:exported="false"
            android:authorities="example.com.fcmproject.firebaseinitprovider"
            android:initOrder="100" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@ref/0x7f0c0003" />

    </application>
</manifest>
Comment 1 James Moore 2017-03-09 22:50:08 UTC
=== Xamarin Studio Professional ===

Version 6.3 (build 831)
Installation UUID: 6dc077b1-7f04-4c1c-b481-1dcbb9a8b0a1
Runtime:
	Mono 4.8.0 (mono-4.8.0-branch/0494d70) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000516

=== NuGet ===

Version: 3.5.0.0

=== Xamarin.Profiler ===

Version: 1.3.2
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 7.2.0.1 (Visual Studio Professional)
Android SDK: /Users/james/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		4.4 (API level 19)
		5.0 (API level 21)
		6.0 (API level 23)
		7.0 (API level 24)
		7.1 (API level 25)

SDK Tools Version: 25.3.1
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 25.0.2

Java SDK: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.Mac ===

Version: 3.2.0.10 (Visual Studio Professional)

=== Xamarin Inspector ===

Version: 1.2.0-rc.2
Hash: 15b00be
Branch: d15-1
Build date: Mon, 06 Mar 2017 15:58:04 GMT

=== Xamarin.iOS ===

Version: 10.8.0.10 (Visual Studio Professional)
Hash: 9995504
Branch: master
Build date: 2017-03-03 17:18:51-0500

=== Build Information ===

Release ID: 603000831
Git revision: 7de8ca50bde6552a271e08e88e99a4e0d30cd384
Build date: 2017-02-27 11:27:41-05
Xamarin addins: 959ddb54b5c8f1d757919063b3e9e7feef7028a7
Build lane: monodevelop-lion-d15-1

=== Operating System ===

Mac OS X 10.12.3
Darwin MacBook-Pro.restphone.com 16.4.0 Darwin Kernel Version 16.4.0
    Thu Dec 22 22:53:21 PST 2016
    root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
Comment 2 James Moore 2017-03-09 23:00:12 UTC
I suppose this is related to https://bugzilla.xamarin.com/show_bug.cgi?id=52857 , but if you don't fix 52857 you're going to need to add a bunch of little ad hoc "well, if they're installing this, we better do this other thing by hand."

Note You need to log in before you can comment on or make changes to this bug.