Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15981] Custom AndroidManifest.xml is being overwritten

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2013-12-16T08:18:42.000+0000
Affected Version/sRelease 3.2.0
Fix Version/s2013 Sprint 26, 2013 Sprint 26 Core, Release 3.2.0, Release 3.3.0
ComponentsAndroid
Labelsandroid-manifest, module_build, overwrite, qe-testadded
ReporterMeenakshi Pathak
AssigneeChris Barber
Created2013-12-13T10:57:08.000+0000
Updated2014-03-13T18:06:45.000+0000

Description

In SDK version 3.2.0, every build replaces the AndroidManifest.xml entries. Even if we delete any 'permission' in the manifest which we don't require for example:
<service android:name="org.appcelerator.titanium.analytics.TiAnalyticsService" android:exported="false"/>
<!-- OR-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
It again shows in the AndroidManifest.xml. *Steps To Reproduce* 1. Create a Titanium project and build it for android device. 2. Copy the AndroidManifest.xml from build folder and paste it under /platform/android folder. 3. Delete any permission let say {}. 4. Again build the project and see that the deleted entry has regenerated again in the custom AndroidManifest.xml again. *Expected Behavior* : If we want to disable any of the permissions, we could do it by making custom androidManifest.xml as we did before SDK version 3.2.0 *Note* : In 3.1.3, Custom AndoidManifest.xml is not being overwritten. Everything works fine as expected.

Comments

  1. Chris Barber 2013-12-16

    Master pull request: https://github.com/appcelerator/titanium_mobile/pull/5123 3.2.x pull request: https://github.com/appcelerator/titanium_mobile/pull/5124
  2. Allen Yeung 2013-12-16

    In the new CLI, we add permissions that are needed for the code to run. If the CLI detects that a certain permission is needed, it will automatically be added, even if you omit it in your custom manifest. The custom android manifest also gets merged with a default one, and any custom manifest properties inside tiapp.xml. If there is a conflict, the value from tiapp.xml takes precedence. There is a problem where the original custom manifest inside platform/android gets overwritten with the default one plus anything from the tiapp.xml. This should not happen, and the PRs mentioned should fix this issue. To test that problem do the following: 1. Build an android app once 2. Copy the AndroidManifest from the build directory and place it in platform/android/AndroidManifest.xml 3. Modify the custom manifest in step 2 to have
       <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="11"/>
       
    4. Inside you tiapp.xml place the following in your android node:
           <android xmlns:android="http://schemas.android.com/apk/res/android">
               <manifest>
                   <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10"/>
               </manifest>
           </android>
       
    Expected: The AndroidManifest inside the build directory should have android:minSdkVersion="10" android:targetSdkVersion="10" AND the custom AndroidManifest inside platform/android should remain UNCHANGED (with a value of android:minSdkVersion="11" android:targetSdkVersion="11" Actual: The custom android manifest in platform/android has android:minSdkVersion="10" android:targetSdkVersion="10"
  3. Priya Agarwal 2013-12-16

    As per document: If there is a conflict between the custom manifest properties and the value from tiapp.xml, then tiapp.xml takes precedence. Now I followed the above mentioned step and got the same result. 
I also tried with test app:
       var performAddressBookFunction = function(){
       	var win = Ti.UI.createWindow();
       var table = Ti.UI.createTableView();
       
       // Repopulate contact data
       function reloadContacts() {
           var contacts = Ti.Contacts.getAllPeople();
           var data = [];
           for (var i = 0; i < contacts.length; i++) {
               var title = contacts[i].fullName;
               if (!title || title.length === 0) {
                   title = "(no name)";
               }
               var row = Ti.UI.createTableViewRow({
                   title: title
               });
               data.push(row);
           }
           table.data = data;
       }
       
       Ti.Contacts.addEventListener('reload', function(e){
           alert('Reloading contacts. Your contacts were changed externally!');
           reloadContacts();
       });
       
       // initial call to populate contact data
       reloadContacts();
       
       win.add(table);
       win.open();
       };
       var addressBookDisallowed = function(){Ti.API.info('Sorry not able to retrieve contacts');};
       if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED){
           performAddressBookFunction();
       } else if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_UNKNOWN){
           Ti.Contacts.requestAuthorization(function(e){
               if (e.success) {
                   performAddressBookFunction();
               } else {
               	
                   addressBookDisallowed();
               }
           });
       } else {
       	
           addressBookDisallowed();
       }
       
    Steps to reproduce: 1)Copy paste the code in app.js of new default classic app. 2) Run the app. 3) Copy the AndroidManifest from the build directory and place it in platform/android/AndroidManifest.xml 4) Delete all the permissions from custom manifest file and run the app again. Expected Result: 1) According to the CLI change app must run successfully but custom manifest file must not change. Actual Result: 1) App runs successfully but custom manifest file also changes. Automatically the removed permissions are added. Though the permissions are added from CLI as they are needed to run the code. But then the custom manifest file must not change. Same code when ran with 3.1.3.GA and 3.1.2.GA using the custom manifest without adding any permissions then we get run time error with message permission denied. Tested Environment: Appcelerator Studio: 3.2.0.201312151544 SDK:3.2.0.v20131215211321 alloy: 1.3.0-cr acs: 1.0.10 npm: 1.3.2 titanium: 3.2.0-cr3 titanium-code-processor: 1.1.0-cr2 Xcode:5.0.2 OS: Mac OSX 10.9 Device: Google Nexus7(v4.3)
  4. Ingo Muschenetz 2013-12-16

    Build failed. Please retry with SDK with SHA https://github.com/appcelerator/titanium_mobile/commit/2a93aca76a566c14e07ea0f42b6e349c9e2a93cb or later.
  5. Lokesh Choudhary 2013-12-17

    Verified the fix. The custom androidmanifest.xml in "platform/android" does not change after building the app. Closing. Environment: Appcel Studio : 3.2.0.201312151544 Ti SDK : 3.2.0.v20131216064236 Mac OSX : 10.8.5 Alloy : 1.3.0-cr CLI - 3.2.0-cr3 Samsung Galaxy S4 running android 4.2.2
  6. Betty Tran 2013-12-17

    I tested and can still reproduce the issue. Here are my environment details: Titanium SDK version: 3.2.0.v20131216191854 CLI version: 3.2.0-cr3 Titanium Studio: 3.2.0.201312162209 Nexus 4, Android 4.4
  7. Allen Yeung 2013-12-17

    [~btran], which issue were you able to reproduce? The original one in the ticket is not a bug, but a new feature with the CLI. It forces some of the permissions back if it detects that the app uses it. Does the AndroidManifest.xml inside platform/android get modified? If so, could you provide more details on what you did. Thanks.
  8. Betty Tran 2013-12-17

    My mistake, I am no longer able to reproduce the problem

JSON Source