Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27325] Android: Adding <uses-library/> within "tiapp.xml" file's <manifest/> block creates invalid entry in "AndroidManifest.xml"

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2020-01-10T15:19:42.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.0.0
ComponentsAndroid
Labelsandroid, cb-tooling, engSchedule, library, manifest, tiapp.xml, xml
ReporterJoshua Quick
AssigneeJoshua Quick
Created2019-08-09T02:56:59.000+0000
Updated2020-01-10T15:19:42.000+0000

Description

*Summary:* Adding a <uses-library/> element within the "tiapp.xml" file's <manifest/> block will create an invalid entry within the generated "AndroidManifest.xml" when doing a build. *Note:* The <uses-library/> entry is supposed to go within the <application/> block, not the <manifest/> block. So, doing this would have been invalid anyways. This makes this bug a very minor issue. https://developer.android.com/guide/topics/manifest/uses-library-element *Steps to reproduce:*

Setting a project's "tiapp.xml" with the <uses-library/> entry below.

Build the project.

Open Finder or Window Explorer.

Go to project's subdirectory: ./build/android

Open the "AndroidManifest.xml" file.

<?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-library android:name="com.google.android.maps"/>
		</manifest>
	</android>
</ti:app>
*Result:* The following invalid XML element can be found within the "AndroidManifest.xml" file. This doesn't prevent the app from running, but it's still not good that this is there.
<uses-library>[object Object]</uses-library>
*Expected Result:* Build system should either omit the <uses-library/> entry or add it as-is. *Solution:* As noted above, the <uses-library/> is supposed to go within the <application/> block. So, all Titanium app devs should be doing the following instead. The build system will correctly inject this into the "AndroidManifest.xml" file.
<?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>
				<uses-library android:name="com.google.android.maps"/>
			</application>
		</manifest>
	</android>
</ti:app>

Comments

  1. Chris Barber 2019-10-02

    I think this is as simple as removing <uses-library> as a valid tag name under the <manifest>: https://github.com/appcelerator/titanium_mobile/blob/master/android/cli/lib/AndroidManifest.js#L376 and https://github.com/appcelerator/titanium_mobile/blob/master/android/cli/lib/AndroidManifest.js#L558
  2. Gary Mathews 2019-12-16

    [~jquick] I see this is _In QE Testing_, is there a PR for this?
  3. Joshua Quick 2019-12-16

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11339 [~gmathews], sorry about that. The above gradle PR solves it because the "AndroidManifest.xml" is merged/validated by Google's build tools. There is already a test written on that PR verifying that this issue will (rightfully) trigger a build failure.
  4. Lokesh Choudhary 2019-12-20

    FR Passed. PR Merged.
  5. Samir Mohammed 2020-01-10

    Closing ticket, fix verified in SDK Version 9.0.0.v20200109153329. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/11339

JSON Source