[TIMOB-27084] Android: "tiapp.xml" is unable to override "AndroidManifest.xml" settings defined in AAR or "timodule.xml"
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-05-23T20:02:44.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 8.0.2 |
Components | Android |
Labels | aar, android, build, engSchedule, manifest, tiapp.xml, timodule |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2019-05-17T03:53:11.000+0000 |
Updated | 2019-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 Create the follow subfolders under the project:
Copy this ticket's [^msal-0.2.2.aar] file to the
Go to the project's
Notice that the
----
*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.
<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
File | Date | Size |
---|---|---|
msal-0.2.2.aar | 2019-05-17T03:27:40.000+0000 | 158980 |
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10884
PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10900
FR passed. jenkin is failing test. waiting for resolving jenkin failure to merge
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}