Bug 13096 - Sample application "Dynamic Test" throws exception during loading on device.
Summary: Sample application "Dynamic Test" throws exception during loading on device.
Alias: None
Product: Android
Classification: Xamarin
Component: Samples ()
Version: 4.7.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 4.8 (async)
Assignee: Jonathan Pryor
Depends on:
Reported: 2013-07-08 10:34 UTC by Mohit Kheterpal
Modified: 2013-07-15 06:54 UTC (History)
2 users (show)

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 or GitHub 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:

Description Mohit Kheterpal 2013-07-08 10:34:53 UTC
Steps to reproduce :
1) Open XS
2) Open Sample application "Dynamic Test" 
3) Build application
4) Debug / Run application on device

Actual : As soon as application launches on device, it throws "System.Reflection.TargetinvocationException."

Expected : Application should run successfully.

Suppliment info :
Device Log : https://gist.github.com/atin360/d98094a7274df9a65d7b

Crash Log :https://gist.github.com/atin360/ba9fab1a22276f6d863b

Android Log :https://gist.github.com/atin360/eb5de735ccf97e8ed499

Application info :

Environment info :
All Mac
XS 4.0.9 (build 15)
Xamarin.Android 4.7.11028
Mono 3.0.12

Regression Status : With stable MFA (4.6.8-7) and stable Mono (2.10.12). We are getting build error for which we are reporting bug 8611
Comment 1 Peter Collins 2013-07-08 14:49:06 UTC
I was able to reproduce on a Galaxy S4 v4.2.2. Assigning to Atsushi as he was the last to contribute to this sample.
Comment 2 Atsushi Eno 2013-07-08 20:35:56 UTC
I cannot reproduce this with Galaxy Note / v4.0.4. Could you try some other devices and see on which devices it fails? Also how about other apps on GS4 in general?
Comment 3 narayanp 2013-07-09 06:49:12 UTC
Today we have checked this issue with following builds:

Mountain Lion
X.S 4.0.9(build 15)
Mono 3.1.1
Xamarin.Android 4.7.11-42

Application DynamicTest working fine and we are not seeing any crash here on Mountain Lion. On Lion we are getting build error for that we have reported an another issue Bug 13114 

Hence, closing this issue
Comment 4 narayanp 2013-07-09 06:50:15 UTC
Checked this application HTC one version 4.0.4
Comment 5 Atsushi Eno 2013-07-09 10:31:48 UTC
But Peter reported that it reproduced on GS4. I guess you should verify it works on GS4/4.2.2, not HTC One/4.0.4.
Comment 6 PJ 2013-07-09 14:33:45 UTC
Hey guys, when Eno asks for testing on multiple devices, don't just give one result without acknowledging his comment.  

With NEEDINFO bugs, you have got to read the comments and give the appropriate information. As Eno asks, which devices work and which do not? It shouldn't take a tremendous amount of time for one tester to cover this app on all the devices you have.
Comment 7 narayanp 2013-07-10 01:50:01 UTC
Today I have checked this issue on same Galaxy S4 4.2.2 and we observed that application launched on device and when we click on Load, Application get crashed and throwing exception "System.Reflection.TargetinvocationException" This is the gist of Application crash: https://gist.github.com/atin360/b2f8cfc0e1371af1bbc5

Mountain Lion
X.S 4.0.9(build 15)
Mono 3.1.1
Xamarin.Android 4.7.11-42

Galaxy S4 version 4.2.2
Comment 8 Atsushi Eno 2013-07-10 02:01:15 UTC
Make sure that the device has internet connection. The sample connects to api.github.com to download the mono commits. I observed the same failure when I didn't enable network on Nexus 7.
Comment 9 narayanp 2013-07-10 10:47:42 UTC
I am having internet connection on device after that I have checked this issue on Galaxy S4 4.2.2 but I am still getting same behavior.
Comment 10 Atsushi Eno 2013-07-10 11:18:11 UTC
Since I haven't done anything about network, all I can do is to delegate this to jonp.
Comment 11 Jonathan Pryor 2013-07-12 12:45:05 UTC
The crash is due to a sample bug.

The problem is that the does:

    var uri = new Uri ((string) item.author.avatar_url);

In which `item.author.avatar_url` is a `dynamic` syntax for navigating JSON. Specifically, _this_ JSON fragment:

>  {
>     "sha": "61cd9ee8b63bdd34fd3b5ebd58f2de3fce507a61",
>     "commit": {
>       "author": {
>         "name": "Alex Rønne Petersen",
>         "email": "alexrp@xamarin.com",
>         "date": "2013-07-11T22:03:02Z"
>       },
>       "committer": {
>         "name": "Alex Rønne Petersen",
>         "email": "alexrp@xamarin.com",
>         "date": "2013-07-11T22:03:02Z"
>       },
>       "message": "Replace more __ARM_ARCH_... checks with HAVE_ARMV<N>.",
>       "tree": {
>         "sha": "d6ae3195c9ba41b34c234eae67dd41de075005f2",
>         "url": "https://api.github.com/repos/mono/mono/git/trees/d6ae3195c9ba41b34c234eae67dd41de075005f2"
>       },
>       "url": "https://api.github.com/repos/mono/mono/git/commits/61cd9ee8b63bdd34fd3b5ebd58f2de3fce507a61",
>       "comment_count": 0
>     },
>     "url": "https://api.github.com/repos/mono/mono/commits/61cd9ee8b63bdd34fd3b5ebd58f2de3fce507a61",
>     "html_url": "https://github.com/mono/mono/commit/61cd9ee8b63bdd34fd3b5ebd58f2de3fce507a61",
>     "comments_url": "https://api.github.com/repos/mono/mono/commits/61cd9ee8b63bdd34fd3b5ebd58f2de3fce507a61/comments",
>     "author": null,
>     "committer": null,
>     "parents": [
>       {
>         "sha": "f99f84a429374f4ce39e8376eb28f23e2a46a759",
>         "url": "https://api.github.com/repos/mono/mono/commits/f99f84a429374f4ce39e8376eb28f23e2a46a759",
>         "html_url": "https://github.com/mono/mono/commit/f99f84a429374f4ce39e8376eb28f23e2a46a759"
>       }
>     ]
>   },

Notice that `author_url` does not appear anywhere within that JSON fragment.

Without the `author_url` JSON key, `(string) item.author.avatar_url` will be `null`, and things crash.
Comment 12 Jonathan Pryor 2013-07-12 12:50:20 UTC
Fixed in monodroid-samples/afff16fe. If `author_url` is missing, we'll just use a default icon.
Comment 14 narayanp 2013-07-15 06:54:43 UTC
Today I have checked this issue with following builds:

X.S 4.0.10
Mono 3.1.1-2

Latest monodroid sample

Now application working fine on Physical devices, checked on
Galaxy S4 version 4.2.2
Google Nexus 4.2.2
HTC One 4.0.4

Changing the status to Verified.