Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes aren't applied to the Android Manifest.xml in godot 4 #82399

Closed
Ayomideabdulazeez opened this issue Sep 26, 2023 · 9 comments
Closed

Comments

@Ayomideabdulazeez
Copy link

Ayomideabdulazeez commented Sep 26, 2023

Godot version

4.1.1

System information

Godot v4.1.stable - Windows 10.0.19045 - Vulkan (Mobile) - dedicated AMD Radeon(TM) RX 560 (Advanced Micro Devices, Inc.; 27.20.2001.8002) - Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz (4 Threads)

Issue description

Intent filters no longer work when they are added to the Android Manifest.xml in the build directory, infact most things don't respond when they are added to the Android Manifext.xml file, it seems like the Engine just ignores any addition that wasn't part of the original Manifest file setup by the engine, you can confirm this by looking at the merge manifest files after exporting the android project, you'll notice that the new changes you added to the android manifest file are not merged

Steps to reproduce

  1. Create a new android game or project in godot 4.1
  2. Install the android build template
  3. In your android/build folder locate the Android Manifest.xml file
  4. Add any new change such as an intent filter for deep linking in the in the Manifest file
  5. Export the project and test your implementation on the device, you'll notice that your expected result don't work on the device, in my casefor deep linking, the game doesn't open with the deep link

Minimal reproduction project

AndroidManifestTest.zip
You can install the andoid build template from the godot project, didn't add it to the file because it was to large, the Android Manifest file is already provided here, once done add a deep link intent filter and call it from the device you'll see that the app doesn't respond

@duarteroso
Copy link

I can confirm that the AndroidManifest.xml is being overwritten when exporting to Android.
In my use case, I want to add a theme which is always removed after each export.

@duarteroso
Copy link

As a matter of fact, it would be nice to have access to the AndroidManifest.xml during the export phase; it would allow devs to add custom parts depending on their configs.

@jemacinnes
Copy link

jemacinnes commented Nov 10, 2023

In my case, I wanted to add support for deep links. Any changes to the default activity section were being overwritten. However, I was able to add an activity-alias with the correct intent filter. The activity-alias was included in the built APKs manifest file....

<activity-alias android:enabled="true"
                android:exported="true"
                android:name=".AppLinkLauncher"
                android:targetActivity="com.godot.game.GodotApp" >
            
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:host="your-domain.com" />
                                    
            </intent-filter>
        
        </activity-alias>

@Virus-Axel
Copy link

Seems like deep links is a desired feature. What if it is implemented as an export option, like "use deeplink" and "scheme". These lines:

<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme=whatever scheme />

could maybe be inserted in the binary manifest in _fix_xml function? I am not super familiar with the manifest format but maybe there is a more generic way to access the manifest when exporting.

@m4gr3d
Copy link
Contributor

m4gr3d commented Dec 8, 2023

The AndroidManifest being overwritten at export time is the intended behavior. In Godot 4.2, the following apis have been added to the EditorExportPlugin to enable programmatic additions of the manifest. This is the recommended approach as it allows to make additions in a way that's compatible with editor upgrades.

Here's an example from the Godot OpenXR plugin, that updates the manifest to include XR related tags and properties.

@m4gr3d m4gr3d removed the bug label Dec 8, 2023
@Iakobs
Copy link

Iakobs commented Dec 8, 2023

The AndroidManifest being overwritten at export time is the intended behavior. In Godot 4.2, the following apis have been added to the EditorExportPlugin to enable programmatic additions of the manifest. This is the recommended approach as it allows to make additions in a way that's compatible with editor upgrades.

* [`_get_android_manifest_activity_element_contents(...)`](https://docs.godotengine.org/en/stable/classes/class_editorexportplugin.html#class-editorexportplugin-private-method-get-android-manifest-activity-element-contents): Allow to update the contents of the activity element in the generated Android manifest

* [`_get_android_manifest_application_element_contents(...)`](https://docs.godotengine.org/en/stable/classes/class_editorexportplugin.html#class-editorexportplugin-private-method-get-android-manifest-application-element-contents): Allow to update the contents of the application element in the generated Android manifest

* [`_get_android_manifest_element_contents(...)`](https://docs.godotengine.org/en/stable/classes/class_editorexportplugin.html#class-editorexportplugin-private-method-get-android-manifest-element-contents): Allow to update the contents of the manifest element in the generated Android manifest

Here's an example from the Godot OpenXR plugin, that updates the manifest to include XR related tags and properties.

Hi @m4gr3d ! I'm not sure if this might be the place to ask this, most likely it is not, but now we can modify the manifest in godot 4.2, but I can't see a way to add new string resources to the android app programatically. Let's say I need to add to the manifest this xml tag in the application block:

<meta-data android:name="com.google.android.gms.games.APP_ID"
      android:value="@string/game_services_project_id"/>

That would be added, but the string resource is not being created. Do you think this might be an interesting feature? Maybe there's a way to achieve this programatically, rather than modifying the android build directly like the android plugins prior to 4.2?

Thanks for your help!

@m4gr3d
Copy link
Contributor

m4gr3d commented Dec 8, 2023

The AndroidManifest being overwritten at export time is the intended behavior. In Godot 4.2, the following apis have been added to the EditorExportPlugin to enable programmatic additions of the manifest. This is the recommended approach as it allows to make additions in a way that's compatible with editor upgrades.

* [`_get_android_manifest_activity_element_contents(...)`](https://docs.godotengine.org/en/stable/classes/class_editorexportplugin.html#class-editorexportplugin-private-method-get-android-manifest-activity-element-contents): Allow to update the contents of the activity element in the generated Android manifest

* [`_get_android_manifest_application_element_contents(...)`](https://docs.godotengine.org/en/stable/classes/class_editorexportplugin.html#class-editorexportplugin-private-method-get-android-manifest-application-element-contents): Allow to update the contents of the application element in the generated Android manifest

* [`_get_android_manifest_element_contents(...)`](https://docs.godotengine.org/en/stable/classes/class_editorexportplugin.html#class-editorexportplugin-private-method-get-android-manifest-element-contents): Allow to update the contents of the manifest element in the generated Android manifest

Here's an example from the Godot OpenXR plugin, that updates the manifest to include XR related tags and properties.

Hi @m4gr3d ! I'm not sure if this might be the place to ask this, most likely it is not, but now we can modify the manifest in godot 4.2, but I can't see a way to add new string resources to the android app programatically. Let's say I need to add to the manifest this xml tag in the application block:

<meta-data android:name="com.google.android.gms.games.APP_ID"
      android:value="@string/game_services_project_id"/>

That would be added, but the string resource is not being created. Do you think this might be an interesting feature? Maybe there's a way to achieve this programatically, rather than modifying the android build directly like the android plugins prior to 4.2?

Thanks for your help!

@Iakobs you can achieve that programmatically by creating an Android plugin that'll contain the resources you want to add.

At export time, the Android plugin binary (.aar file) gets merged with the project and that merge includes the resources.

For information on the Android plugin, see https://docs.godotengine.org/en/stable/tutorials/platform/android/android_plugin.html

@Iakobs
Copy link

Iakobs commented Dec 9, 2023

@Iakobs you can achieve that programmatically by creating an Android plugin that'll contain the resources you want to add.

At export time, the Android plugin binary (.aar file) gets merged with the project and that merge includes the resources.

For information on the Android plugin, see https://docs.godotengine.org/en/stable/tutorials/platform/android/android_plugin.html

Oh damn, you're right! thanks a lot, I always forget about the manifest merging!

@m4gr3d
Copy link
Contributor

m4gr3d commented Feb 13, 2024

Closing this issue as #82399 (comment) describes the process to apply changes to the AndroidManifest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants