Bug 19940 - APK will crash on start if system time is changed to before install date
Summary: APK will crash on start if system time is changed to before install date
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: 3.0
Hardware: PC Windows
: Normal normal
Target Milestone: 3.1
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2014-05-20 13:26 UTC by John Miller [MSFT]
Modified: 2014-06-05 07:18 UTC (History)
8 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description John Miller [MSFT] 2014-05-20 13:26:49 UTC
## Overview: 

    An APK will crash on launch if the system time is changed to before the install time of the APK.

## Steps to Reproduce: 

    1. Build and Deploy app to a device (I used the HelloWorld example from New -> Android Project).
    2. Launch it to confirm it works.
    3. Swipe it out of memory to force close it.
    4. Open Settings app, uncheck automatic time and change date/time to before the install time (back a few hours or days)
    5. Launch the original APK again, it will crash (or sometimes hang forever)
    6. (Optional) Change the system time back to current time, and launch the app. It should work.

## Actual Results: 

    App crashes or hangs when launched. 

## Expected Results: 

    App launches normally.

## Build Date & Platform: 

    VS 2013
    XA 2.0.100.0

## Additional Information: 

    The logcat shows the following:

    W/MonoDroid-Debugger(31954): Trying to initialize the debugger with options: --debugger- agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8839,server=y,embedding=1
    W/ActivityManager(25916): Launch timeout has expired, giving up wake lock!
    E/WindowManager(25916): Starting window AppWindowToken{45317b68 token=Token{42b3e090 ActivityRecord{42b9a958 u0 AndroidApplication4.AndroidApplication4/androidapplication4.MainActivity t140}}} timed out

    The APK was built from the command line using (Same results when deploying from VS):
    msbuild /t:Install "path/to/project.csproj"

    App is being launched by touching it on the device to launch it, not using the IDE. 

    adb shell getprop debug.mono.extra shows this:
    debug=127.0.0.1:8839:8840,timeout=1400600126,loglevel=0,server=y

    Test was not using the IDE, so not sure how any timeouts get set, or why its waiting since its not connected to IDE/Windows.
    Sane Actual Results when running the same test with Visual Studio to deploy the apk.
Comment 1 John Miller [MSFT] 2014-05-20 13:28:00 UTC
## Additional Information (cont.)

    If the APK is built from Xamarin Studio (on Mac), the Actual Results are different. The APK will not crash after changing the system time.
Comment 2 John Miller [MSFT] 2014-05-20 13:32:06 UTC
## Workaround

    Running the following command with the device connected will remove the timeout setting
    adb shell setprop debug.mono.extra "

   Now the APK will launch after the system time is changed.
Comment 3 Jonathan Pryor 2014-05-20 17:20:10 UTC
Visual Studio needs to clear out the debug.mono.extra system property after launching the target process.
Comment 4 Sunil Kumar 2014-05-22 07:11:15 UTC
We have tried to reproduce this issue and we are also getting the same behavior. If we change date/time to before the install time (back a few hours or days)and  Launch the original APK again in release mode then app gets crash and in debug mode, it shows the black screen and hang. If we change the system time back to current time and launch the app. It works fine.

Android Device log: https://gist.github.com/sunil360/19599aa3ddacd3b6b665

Environment info:
Samsung Galaxy 2 (Android Version 2.3.3)
Samsung Galaxy 4 (Android Version 4.2.2)
VS 2013/2012
XVS 2.00.114.0
Comment 5 Jonathan Pryor 2014-05-22 08:36:44 UTC
It's freezing because it's trying to attach to the debugger:

> 05-22 15:15:43.970 W/MonoDroid-Debugger(11279): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8961,server=y,embedding=1

See Comment #3.
Comment 6 dean.ellis 2014-06-03 09:19:37 UTC
Fixed in XamarinVS/master/7325b43278
Comment 7 Akhilesh kumar 2014-06-05 07:18:40 UTC
I have checked this issue with following builds:

VS 2013
Xamarin 3.1.159.0 (c376d19d2984310ff50a6e741e3e3e9ce4f920a5)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android

Device info:
Samsung Galaxy 2 (Android Version 2.3.3)

I have tried following steps:
1. Created iOS application in VS
2. Deploy the application on device on RELEASE mode
3. Confirm that application launches successfully
4. Force close the application from Settings
5. Open Settings app, uncheck automatic time and change date/time to before
the install time (back a few hours)
6. Now again open the application

This time application launches successfully and it does not crash.