Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27304] Android: Setting <uses-feature/> required "true" in "tiapp.xml" should override "false" setting in libraries

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2019-08-21T11:36:11.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.1.1
ComponentsAndroid
Labelsandroid, engSchedule, manifest, modules, xml
ReporterJoshua Quick
AssigneeJoshua Quick
Created2019-08-02T21:18:16.000+0000
Updated2019-08-30T07:19:30.000+0000

Description

*Summary:* The "AndroidManifest.xml" file's <uses-feature/> "android:required" attribute value can be set to true or false. When multiple manifests declare the same <uses-feature/>, the merge process must do a logical OR of these values. This means that if one of the manifest files sets it to true, it can be made false at the end of the XML merge. (The true setting wins.) https://developer.android.com/studio/build/manifest-merge When the Titanium build merges "timodule.xml" and "tiapp.xml" settings, it does not "OR" the "android:required" values. Instead the original "timodule.xml" value always wins. This means if the "timodule.xml" sets it false, the "tiapp.xml" is never able to set it true. (The reverse is not an issue though.) *Note:* The behavior of the XML merge has changed as of Titanium 8.0.2. Before 8.0.2, the "tiapp.xml" manifest settings used to blindly overwrite the "timodule.xml" manifest settings, which was not technically correct but did allow the "tiapp.xml" to override <uses-feature/> to true or false (it still wasn't ORing the values though). Titanium 8.0.2 improved the merge to better follow Google's merging rules, but it is not ORing the values which is what's needed. *Steps to reproduce:*

Create a Classic Titanium app project.

Add modules "ti.barcode" to "tiapp.xml". (Can download from [here](https://github.com/appcelerator-modules/ti.barcode).)

Add the <uses-feature/> settings in "tiapp.xml" as shown below.

Build for Android.

Open Mac's "Finder" window. (Or "Windows Explorer" on Windows.)

Go to project subdirectory: ./build/android

Open file "AndroidManifest.xml".

Observe its <uses-feature/> XML elements.

<?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>
			<uses-feature android:name="android.hardware.camera" android:required="false"/>
			<uses-feature android:name="android.hardware.touchscreen" android:required="true"/>
		</manifest>
	</android>
	<modules>
		<module platform="android">ti.barcode</module>
	</modules>
</ti:app>
*Result:* The merged "AndroidManifest.xml" file's <uses-feature/> for "android.hardware.touchscreen" is false when it should be true. *Expected Result:* The <uses-feature/> for "android.hardware.touchscreen" should be true, not false. The values need to be OR'ed together.

Comments

  1. Joshua Quick 2019-08-03

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11110 PR (8.1.x): https://github.com/appcelerator/titanium_mobile/pull/11111
  2. Satyam Sekhri 2019-08-05

    FR passed. Correct value of elements in manifest file based on OR(ing) of values from all the involved xml files. Waiting for the merge of PR's
  3. Joshua Quick 2019-08-14

    PR (8.3.x): https://github.com/appcelerator/titanium_mobile/pull/11146
  4. Satyam Sekhri 2019-08-14

    FR Passed. Waiting on Jenkins build to pass.
  5. Christopher Williams 2019-08-20

    Merged to master, 8_3_X and 8_1_X
  6. Samir Mohammed 2019-08-21

    *Closing ticket* fix verified in SDK version 8.2.0.v20190820104021, 8.1.1.v20190820143437 and 8.3.0.v20190820103430. Test and other information can be found at: PR (master): https://github.com/appcelerator/titanium_mobile/pull/11110 PR (8.1.x): https://github.com/appcelerator/titanium_mobile/pull/11111 PR (8.3.x): https://github.com/appcelerator/titanium_mobile/pull/11146
  7. Pietro Granati 2019-08-30

    Thank you for resolving this!

JSON Source