Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27084] Android: "tiapp.xml" is unable to override "AndroidManifest.xml" settings defined in AAR or "timodule.xml"

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2019-05-23T20:02:44.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.0.2
ComponentsAndroid
Labelsaar, android, build, engSchedule, manifest, tiapp.xml, timodule
ReporterJoshua Quick
AssigneeJoshua Quick
Created2019-05-17T03:53:11.000+0000
Updated2019-05-23T20:02:44.000+0000

Description

*Summary:* The "tiapp.xml" file's "AndroidManifest.xml" settings is unable to override the XML elements such as <activity/>, <receiver/>, etc. that are defined in a native module's "timodule.xml" or a native AAR library's embedded "AndroidManifest.xml". *Example Use-Case:* Microsoft's authentication library (aka: MSAL) requires the app developer to override its com.microsoft.identity.client.BrowserTabActivity in the app project's "AndroidManifest.xml" and add an intent-filter to it. This is needed the Chrome web browser app will return the end-user back to the app that requested single-signon. https://github.com/Azure-Samples/ms-identity-android-native *Steps to Reproduce:*

Create a Titanium Classic "Default Project".

Insert the android manifest XML settings below into the "tiapp.xml" file.

Create the follow subfolders under the project: ./platform/android

Copy this ticket's [^msal-0.2.2.aar] file to the ./platform/android folder.

Build the app for Android.

Go to the project's ./build/android directory via Finder/WindowsExplorer.

Open the "AndroidManifest.xml" file.

Notice that the <intent-filter/> shown below was not injected into the "AndroidManifest.xml" file. _(This is the bug.)_

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
	<android xmlns:android="http://schemas.android.com/apk/res/android">
		<manifest>
			<application>
				<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
					<intent-filter>
						<action android:name="android.intent.action.VIEW"/>
						<category android:name="android.intent.category.DEFAULT"/>
						<category android:name="android.intent.category.BROWSABLE"/>
						<data android:scheme="msauth" android:host="my.domain.com" android:path="my-path"/>
					</intent-filter>
				</activity>
			</application>
		</manifest>
	</android>
</ti:app>
*Recommended Fix:* We should change the finalAndroidManifest merge order in the SDK's "_build.js" script [here](https://github.com/appcelerator/titanium_mobile/blob/2a16df7481b0a3331d2f56365463f0a9a8031d09/android/cli/commands/_build.js#L3909). The order should be:

this.androidLibraries.forEach(/* finalAndroidManifest.merge(am) */)

this.modules.forEach(/* finalAndroidManifest.merge(am) */)

finalAndroidManifest.merge(customAndroidManifest)

finalAndroidManifest.merge(tiappAndroidManifest)

---- *Work-Around:* Delete the XML setting that you want to override from the "timodule.xml" file or AAR file. Note that you can unzip an AAR file, change its embedded "AndroidMainfest.xml" file, and then re-zip it. Changing the AAR library's extension from ".aar" to ".zip" is an easy way to unzip it.

Attachments

FileDateSize
msal-0.2.2.aar2019-05-17T03:27:40.000+0000158980

Comments

  1. Joshua Quick 2019-05-17

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10884
  2. Joshua Quick 2019-05-18

    PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10900
  3. Keerthi Mahalingam 2019-05-21

    FR passed. jenkin is failing test. waiting for resolving jenkin failure to merge
  4. Keerthi Mahalingam 2019-05-23

    Verified the fix on SDK 8.1.0.v20190523084559 and 8.0.2.v20190522031334. Works as expected. {CODE} Operating System Name = Mac OS X Version = 10.13.6 Architecture = 64bit # CPUs = 8 Memory = 17179869184 Node.js Node.js Version = 8.9.1 npm Version = 5.5.1 Titanium CLI CLI Version = 5.1.1 Titanium SDK SDK Version = 8.1.0.v20190523084559 and 8.0.2.v20190522031334 Cli =7.0.11 Studio =5.1.2.201903111843 {CODE}

JSON Source