Bug 48508 - Archiving Android application is archiving old builds
Summary: Archiving Android application is archiving old builds
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: 7.0 (C8)
Hardware: Macintosh Mac OS
: High normal
Target Milestone: 7.1 (C9)
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2016-12-01 02:50 UTC by kizari93
Modified: 2017-01-12 14:27 UTC (History)
6 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description kizari93 2016-12-01 02:50:50 UTC
I have my Android project set as the startup project, set to release > android device.

After making changes to project code, and selecting [Build > Archive for Publishing] from the menu, the build is successful and the archive opens, with a new entry. I sign this build and save it to disk as an .apk file, but upon installing this on my Android device, it becomes apparent the code changes are not present in the build. I have to force quit Xamarin Studio and repeat the steps above to get the code changes to present themselves in the build.

Additional Information:

- This was present on the previous version (6.1.1) but was able to be fixed by repeating the archive process without force quitting Xamarin Studio first

- If I change the version number in AndroidManifest.xml after making the code changes, the archived build will show the previous version number

- This does not affect my iOS builds
Comment 1 Greg Munn 2016-12-01 16:31:12 UTC
I will try to investigate this, but I'm curious, you have to "force quit" Xamarin Studio? Xamarin Studio won't quit by itself?

Some things you can attach to the bug report, the logs from Help | Open Log Directory -  reproduce the error and the force quit.

Before force quitting XS and grabbing the logs, in Terminal, do 

> kill -quit <process id of XS>

(get the process id from activity monitor)
Comment 2 Greg Munn 2016-12-01 17:06:45 UTC
I did reproduce this. I'm not completely sure how your workaround fixes it for you, it appears to require a clean for me.

Here were my repro steps (both in XS and on the cmdline)

1. Create a new android project
2. Switch to release configuration
3. Archive for Publishing
4. Sign and distribute the created archive to file (Desktop for example)
5. Using `adb install <apk file name>`, install the app
6. Run the app to see the default behaviour
7. Edit MainActivity.cs and change the label, display text etc
8. Archive for Publishing again
9. Sign and distribute the selected app, use same or different location, does not matter
10. uninstall the existing app `adb uninstall <packagename>`
11. install the updated apk, `adb install <apk file name>`
12. run the app and notice that the none of the changes were deployed

cmdline repro

1. Create a new android project
2. `xbuild /p:Configuration=Release /t:Build`
3. `xbuild /p:Configuration=Release /t:PackageForAndroid` (this is what XS uses to create the initial apk to store in the archive).
4. Verify that the .apk was created, look at its timestamp
5. Wait a little, makes looking at timestamps easier
6. make the same edits in step 7 from prior repro steps
7. `xbuild /p:Configuration=Release /t:Build`
8. `xbuild /p:Configuration=Release /t:PackageForAndroid`
9. Look at the timestamps of the files
10. the timestamp of the .apk does not change, the build output from packageForAndroid indicates that it did nothing.


I think that's why the archive isn't updated. We don't get an updated .apk.
Comment 3 Greg Munn 2016-12-01 17:07:36 UTC
@dean can you verify this?
Comment 4 kizari93 2016-12-03 02:36:21 UTC
My apologies, I need to correct myself. I'm primarily a windows user and only use my macbook pro for Xamarin, so I'm not entirely familiar with the operating system. Closing the app with the red button in the top-left corner wasn't actually closing Xamarin Studio, just minimising it. Upon further inspection I now realise there's an option to quit normally from the Xamarin Studio menu, which is in fact adequate to exit the program as you suspected.

My most recent force quit also failed to fix the issue this time, so perhaps something in the force quit had triggered the app to do a clean build last time as possibly shown by the increased build time (this is all just speculation though).

Here are the steps I took to verify your solution:

1. Select Android project as startup project
2. Perform Clean
3. Build the project
4. Archive for publishing
5. Save to disk
6. Transfer .apk file onto Android device
7. Install and verify changes are now present
Comment 5 dean.ellis 2016-12-13 15:08:04 UTC
PR is up https://github.com/xamarin/xamarin-android/pull/333
Comment 6 dean.ellis 2016-12-13 16:38:23 UTC
Fixed in xamarin-android/master/20832a61
Comment 8 Shruti 2017-01-10 08:16:11 UTC
@Dean, Please fix the commit in C9. It will help us to verify and close this issue.
Comment 9 dean.ellis 2017-01-10 17:06:18 UTC
fixed in monodroid/cycle9/3819c645

VS will need to be bumped but the mac build should be ok.
Comment 10 Sunil Kumar 2017-01-12 14:27:33 UTC
I have checked this issue on Mac with latest C9 XamarinStudio-6.2.0.1730_058f8df13bdfe48e4cba6021b876e4f66943a099 and xamarin.android-7.1.0-21 and on Windows VS with Xamarin.VisualStudio_4.3.0.561_48809a62ab179f5898f3bf0e1b9abd441840eabf and observed that now this issue is working fine. After make changes and creating the new .apk using [Build > Archive for Publishing] option from menu then changes are reflecting correctly in new build.

Hence I am closing this issue.

Environment info:
Mac: https://gist.github.com/sunil360/652754be42b5c6ad2b3a4583f6ecf199
Windows: https://gist.github.com/sunil360/0c5a12ef3186d71947a0f6978fa4d0dc

Note You need to log in before you can comment on or make changes to this bug.