[TIMOB-27325] Android: Adding <uses-library/> within "tiapp.xml" file's <manifest/> block creates invalid entry in "AndroidManifest.xml"
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Low |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2020-01-10T15:19:42.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 9.0.0 |
| Components | Android |
| Labels | android, cb-tooling, engSchedule, library, manifest, tiapp.xml, xml |
| Reporter | Joshua Quick |
| Assignee | Joshua Quick |
| Created | 2019-08-09T02:56:59.000+0000 |
| Updated | 2020-01-10T15:19:42.000+0000 |
Description
*Summary:*
Adding a Setting a project's "tiapp.xml" with the
Go to project's subdirectory:
<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>
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[~jquick] I see this is _In QE Testing_, is there a PR for this?
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.
FR Passed. PR Merged.
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