gree / unity-webview

zlib License
2.31k stars 695 forks source link

WebView and Firebase integration failing due to manifest file overriding #516

Open ankit17737 opened 4 years ago

ankit17737 commented 4 years ago

I imported Firebase Auth in my project and implemented entire login approach, now once the user is logged in I want to show them with WebView.

The issue is when I am setting up the webview as per steps and then try to build the apk. The webview manifest overrides the manifest file and then the building of apk fails with error "Android Resource Linking Failed".

I tried:

  1. Reimporting Firebase after WebView
  2. With new project also.
  3. Reimporting WebView also.

The issue is that the Manifest file made for WebView is overriding the Manifest file required for Firebase. Screenshot (37) Screenshot (38)

ankit17737 commented 4 years ago

Unity Version: Unity 2019.2.17f1

KojiNakamaru commented 4 years ago

I tested to build the sample app with the following steps:

  1. Open the sample app with 2019.2.17f1 on OSX.
  2. Import unity-webview.unitypackage.
  3. Set Api Compatibility Level to .NET 4.x.
  4. Import FirebaseAuth.unitypackage.
  5. Apply Google Version Handler.
  6. Switch Platform to Android (which also invokes Android Resolver).
  7. Build an apk.

Though I haven't create any app on Firebase Console, I can successfully build the app and the resulting apk has the following lines in AndroidManifest.xml.

...
        <activity
            android:label="@ref/0x7f090000"
            android:name="com.unity3d.player.UnityPlayerActivity"
            android:launchMode="2"
            android:screenOrientation="6"
            android:configChanges="0x40003fff"
            android:hardwareAccelerated="true">
...
        <service
            android:name="com.google.firebase.components.ComponentDiscoveryService"
            android:exported="false"
            android:directBootAware="true">

            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />

            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />

            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
        </service>

        <activity
            android:theme="@ref/0x01030010"
            android:name="com.google.firebase.auth.internal.FederatedSignInActivity"
            android:permission="com.google.firebase.auth.api.gms.permission.LAUNCH_FEDERATED_SIGN_IN"
            android:exported="true"
            android:excludeFromRecents="true"
            android:launchMode="2" />

        <provider
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:exported="false"
            android:authorities="net.gree.webview.sample.firebaseinitprovider"
            android:initOrder="100" />

        <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" />
            </intent-filter>
        </receiver>
...

so it seems to work okay, where the former part contains android:hardwareAccelerated="true" which is imported by the following code (note: it is actually placed under Assets/Plugins/Editor),

https://github.com/gree/unity-webview/blob/d408b5e5bcd2251d6794f16424e173f68a0752d0/plugins/Editor/UnityWebViewPostprocessBuild.cs#L22-L36

and the latter part should be imported by Firebase SDK.

Could you please try to comment out the above OnPostGenerateGradleAndroidProject() and build your app? Then at least this plugin do nothing for AndroidManifest.xml so we can reduce the issue. It is also nice if you could provide a tiny sample app that reproduce the issue.