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

Unable to modify AndroidManifest.xml. #76963

Closed
AK-T90 opened this issue May 11, 2023 · 14 comments · Fixed by #78958
Closed

Unable to modify AndroidManifest.xml. #76963

AK-T90 opened this issue May 11, 2023 · 14 comments · Fixed by #78958

Comments

@AK-T90
Copy link

AK-T90 commented May 11, 2023


Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version

v4.0.2.stable.official [7a0977c]

System information

Ubuntu 22.04

Issue description

I followed this tutorial
https://docs.godotengine.org/en/stable/tutorials/export/android_custom_build.html#doc-android-custom-build.

I want to create Android launcher app to do this i added following code to AndroidManifest.xml in Android Studio.
<category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" />

But when I export APK my modifications are removed from AndroidManifest.xml.

Steps to reproduce

Followed this tutorial
https://docs.godotengine.org/en/stable/tutorials/export/android_custom_build.html#doc-android-custom-build.

then open android project in Android studio and edit AndroidManifest.xml.

Minimal reproduction project

N/A

@vladimirgamalyan
Copy link

The same issue on 4.0.3.stable

@Abab-bk
Copy link

Abab-bk commented Jun 27, 2023

Same problem, I really need it, otherwise my game will be removed for alleged invasion of privacy.

@akien-mga
Copy link
Member

While #78164 solves the OP's need to set an application as launcher, the claim that it's not possible to modify the AndroidManifest.xml manually for custom builds needs to be looked into separately, as being able to do this was definitely part of the intention with this build process.

@Abab-bk
Copy link

Abab-bk commented Jun 27, 2023

While #78164 solves the OP's need to set an application as launcher, the claim that it's not possible to modify the AndroidManifest.xml manually for custom builds needs to be looked into separately, as being able to do this was definitely part of the intention with this build process.

I just did it again from scratch and it worked, but my application got an error, despite that, AndroidManifest.xml was still modified.

@FoolLin
Copy link

FoolLin commented Jun 27, 2023

@Abab-bk How did you able to modify AndroidManifest.xml? Is there a workaround?

@Abab-bk
Copy link

Abab-bk commented Jun 27, 2023

@Abab-bk How did you able to modify AndroidManifest.xml? Is there a workaround?

I just did it three times from the beginning and it worked on the third time.

@FoolLin
Copy link

FoolLin commented Dec 2, 2023

I'm still having this issue in v4.2.stable while trying to add an additional "intent" to AndroidManifest.xml.

@m4gr3d
Copy link
Contributor

m4gr3d commented Dec 3, 2023

I'm still having this issue in v4.2.stable while trying to add an additional "intent" to AndroidManifest.xml.

@FoolLin The following apis have been added to the EditorExportPlugin to enable programmatic modifications of the manifest:

@FoolLin
Copy link

FoolLin commented Dec 10, 2023

@m4gr3d I've overwritten _get_android_manifest_activity_element_contents(...) and I'm not sure what kind of string should be returned. I've tried to return the entire activity section from the .xml file including the "intent" part and put it in the ''', but nothing changed when I checked. I've also tried using the print(...) inside the _get_android_manifest_activity_element_contents(...) to see if the method is even called and received silence, unlike the _export_begin(...), which print when export started. Am I misunderstanding on how to use this?

@m4gr3d
Copy link
Contributor

m4gr3d commented Dec 10, 2023

@m4gr3d I've overwritten _get_android_manifest_activity_element_contents(...) and I'm not sure what kind of string should be returned. I've tried to return the entire activity section from the .xml file including the "intent" part and put it in the ''', but nothing changed when I checked. I've also tried using the print(...) inside the _get_android_manifest_activity_element_contents(...) to see if the method is even called and received silence, unlike the _export_begin(...), which print when export started. Am I misunderstanding on how to use this?

@FoolLin can you provide a minimal reproducible project with the changes you made as described above.

@FoolLin
Copy link

FoolLin commented Dec 11, 2023

@FoolLin can you provide a minimal reproducible project with the changes you made as described above.

Here is Minimal Reproducible(4.2).zip but it doesn't contain android folder since GitHub said it too big.

In v3.5.3 I'm able to directly modify AndroidManifest.xml to something like this
AndroidManifest.zip. When exported, there should be supported links shown inside the app info.

@m4gr3d
Copy link
Contributor

m4gr3d commented Dec 11, 2023

@FoolLin From looking at your MRP, you need to override EditorExportPlugin#_supports_platform(...) and return true for the Android platform (the default value if not overridden is false).

The _get_android_manifest_activity_element_contents method should only return xml elements that can be contained within the <activity>...</activity> element as defined in https://developer.android.com/guide/topics/manifest/activity-element.
So for your MRP that should be:

                         <intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.DEFAULT" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>

			<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="https"
					android:host="play.examplegame.net"
					android:pathPattern="/.*" />
			</intent-filter>

Also note that the first intent-filter is already defined in the default AndroidManifest.xml so you don't need to repeat it here as well.

@BraveEvidence
Copy link

I have two questions for this

  1. Suppose I am launching my app using a Depp link, how to get the data from my deep link. In Native Android we use intent.data, what's the equivalent in godot?
  2. How to launch a deeply nested scene of my game in Godot. In Native android we can select which activity to launch by Deep-link but in godot we only have one activity?

@m4gr3d
Copy link
Contributor

m4gr3d commented Jun 2, 2024

@BraveEvidence This issue is closed and your topic doesn't seem related to it.

Instead you can either ask the community forums, or our rocket chat dev community.

@AThousandShips AThousandShips added this to the 4.2 milestone Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants