Bug 12215 - deploying/debugging a newly create Xamarin.Android project fails, when old ones connect correctly
Summary: deploying/debugging a newly create Xamarin.Android project fails, when old on...
Status: RESOLVED DUPLICATE of bug 11679
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.6.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2013-05-13 07:48 UTC by Philippe Monteil
Modified: 2013-05-15 02:13 UTC (History)
2 users (show)

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

Device Deployment log (19.04 KB, application/octet-stream)
2013-05-13 15:10 UTC, Philippe Monteil
LogCat (248.98 KB, application/octet-stream)
2013-05-13 15:11 UTC, Philippe Monteil
a simple solution built with 4.0.5, showing the deployment and debugging problems (4.27 MB, application/x-zip-compressed)
2013-05-14 02:44 UTC, Philippe Monteil
Device Deployment Log (5.43 KB, application/octet-stream)
2013-05-14 12:31 UTC, Philippe Monteil
logcat_051413_1815.log (293.91 KB, application/octet-stream)
2013-05-14 12:37 UTC, Philippe Monteil

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 Philippe Monteil 2013-05-13 07:48:31 UTC
Description of Problem:

using Xamarin.Studio 4.0.5 / Windows,
deploying, debugging a newly create Xamarin.Android project fails,
when old ones deploy and connect correctly

Steps to reproduce the problem:
1. use a solution with existing Android applications
2. create a new Android application in it
3. try to deploy it to a device
4. try to debug it

Actual Results:

1) The newly created application cannot be deployed as is: the foolowing messages are obtained in the 'Deploy Device' window:
  Deployment failed because the FastDev assembly directory could not be created.
  Deployment failed. FastDev directory creation failed.
The problem is fixed by unchecking the 'Fast assembly deployment' option,
which is not necessary with a project created with the previous version of Xamarin Studio.

2) There is now way to to connect the debugger to the application launched on a device 

How often does this happen? 
each time

Additional Information:
Comment 1 Mikayla Hutchinson [MSFT] 2013-05-13 14:22:07 UTC
What version of Xamarin.Android?
Comment 3 Philippe Monteil 2013-05-13 15:10:24 UTC
Created attachment 3956 [details]
Device Deployment log

The attached Device Deployment log show two different attemps to deploy the same Test application:
for the first one, the 'Fast assembly deployment' option is checked (failure), not for the second one (success).
Comment 4 Philippe Monteil 2013-05-13 15:11:09 UTC
Created attachment 3957 [details]
Comment 5 Philippe Monteil 2013-05-13 15:12:02 UTC
Xamarin Studio
Version 4.0.5 (build 4)
Installation UUID: 8afc55fa-7748-46a1-9b38-2b47153ebab8
	Microsoft .NET 4.0.30319.18033
	GTK 2.24.13
	GTK# (

Version: 4.6.4 (Indie Edition)
Android SDK: C:\Users\phili_000\AppData\Local\Android\android-sdk
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39

Build Information
Release ID: 400050004
Build date: 2013-05-03 15:42:50Z
Xamarin addins: 603116b3659f75acbed00d7786768d2578832599

Operating System
Windows 6.2.9200.0 (64-bit)
Comment 6 Jonathan Pryor 2013-05-13 15:34:59 UTC
This looks like a dup of Bug #11421.

There are two runtimes: the Debug/SharedRuntime and the Release/!SharedRuntime runtimes.

The Debug runtime always creates the fast deployment directory. The Release runtime does not.

A "Debug" build with the "Use shared runtime" checkbox _disabled_ uses the Release runtime.

Since your fast deployment directory isn't being created, I suspect that you're using the Release runtime. If you want to use Fast Deployment _without_ the shared runtime, then you will need to provoke the Release runtime to create the directory:

    adb shell setprop debug.mono.log gc

Furthermore, I suspect that you're building a non-Debug build, because the debugger can't connect:

> W/MonoDroid-Debugger( 3017): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=,server=y,embedding=1
> E/MonoDroid-Debugger( 3017): Could not construct a socket for stdout and stderr
> I/ActivityManager(  477): Process Test.Test (pid 3017) has died.

The reason that the socket couldn't be constructed is (usually) because your app lacks the INTERNET permission, which is always added for Debug builds. Thus I suspect a Release build.
Comment 7 Philippe Monteil 2013-05-14 02:44:47 UTC
Created attachment 3961 [details]
a simple solution built with 4.0.5, showing the deployment and debugging problems
Comment 8 Philippe Monteil 2013-05-14 02:46:58 UTC
All I do is create a new app either in an existing of new solution and hit 'debug'.
The applicatins and solutions created before 4.0.5 deploy and debug fine.
Comment 9 Mikayla Hutchinson [MSFT] 2013-05-14 03:03:46 UTC
Jon, the AndroidTools log shows the debug runtime being installed. But the logcat log doesn't show the Seppuku broadcast, so I don't think the logcat log matches the AndroidTools log.
Comment 10 Philippe Monteil 2013-05-14 04:12:29 UTC
I have made more tests, in case it helps:

- loading a project created with 4.0.5 with VS.Net 2012 causes the same
  deployment / debugging problems
- creating a new project with VS.Net 2012 and then loading, deploying, debugging it with 4.0.5 works fine and provides a temporary workaround,

EXCEPT that now all the new projects, even in new solutions, I create using Xamarin.Studio show the 'Built with evaluation software' initial screen,
despite my 'Indie' licence ...
Comment 11 Jonathan Pryor 2013-05-14 11:53:57 UTC
@Philippe: Please try restarting your Android device, re-deploying your app from Xamarin Studio, and providing the most recent AndroidTools and logcat output. As Michael mentioned in Comment #9, the current log files don't seem self-consistent, in that AndroidTools-2013-05-13__20-46-13.log clearnly mentions sending a SEPPUKU broadcast, while logcat.log doesn't mention that broadcast.

What Android version is your target device running? Is it Android 3.2, by any chance?  (Bug #11401).
Comment 12 Philippe Monteil 2013-05-14 12:31:50 UTC
Created attachment 3966 [details]
Device Deployment Log

This is the Device Deployment Log obtained after having rebooted the device,
a Nexus7 running Android 4.2.1.
A new solution and a new application were built from scratch 
with Xamarin Studio 4.0.5 (b4) and then
- deployed as is
- deployed hafter having unchecked the 'Fast assembly deployment' option.
Comment 13 Philippe Monteil 2013-05-14 12:37:14 UTC
Created attachment 3967 [details]

latest LogCat (05/14/13 18:15)
Comment 14 Philippe Monteil 2013-05-14 12:39:50 UTC
I insist that:
- an application built using an older version than 4.0.5 deploys and debugs ok.
- an application created with VS.Net 2012 / Android  deploys and debugs ok
  as well.
in case it helps...
Comment 15 Jonathan Pryor 2013-05-14 16:54:02 UTC

Please edit your .csproj and ensure that the following is within the "Debug|AnyCPU" <PropertyGroup/>:


Then clean and rebuild your project.


Unfortunately, we still find the log files to be confusing.

In Comment #12 you mention that you're performing _two_ installs, one "as is" (implying with fast deployment enabled), and one without fast deployment enabled.

logcat_140513.log partially bears this out, in that there are two package installs:

# line 1924:
> D/PackageManager(  484): New package installed in /data/app/Test_140513_1815.Test_140513_1815-1.apk
# line 2043:
> D/PackageManager(  484): New package installed in /data/app/Test_140513_1815.Test_140513_1815-1.apk

However, part of the fast deployment process involves sending a "SEPPUKU" broadcast, which isn't present:

> # Similar to expected, not found in logcat_140513.log:
> I/ActivityManager(  394): Start proc SvgAndroidSample.SvgAndroidSample for broadcast SvgAndroidSample.SvgAndroidSample/mono.android.Seppuku: pid=17223 uid=10147 gids={50147, 3003, 1028}

So the package is being installed twice, but neither install is using fast deployment. :-/

Furthermore, AndroidTools-2013-05-14__18-20-41.log only mentions _one_ install, and that install likewise isn't following normal fast deployment.

If I look at Attachment #3961 [details] (from Comment #7), I see that Test_140513/Test_140513/Test_140513.csproj _disables_ fast deployment:


When $(EmbedAssembliesIntoApk) is True, fast deployment is not used, and $(EmbedAssembliesIntoApk) is set in the Debug|AnyCPU configuration. I don't know if Attachment #3961 [details] corresponds to your "deployed as is" entry or your "deployed hafter having unchecked the 'Fast assembly deployment' option" entry.

Skipping the fast deployment confusion for now, I'll return to logcat_140513.log, which has this interesting _repeated_ sequence:

> I/ActivityManager(  484): Start proc Test_140513_1815.Test_140513_1815 for activity Test_140513_1815.Test_140513_1815/test_140513_1815.test_140513_1815.TrialSplashScreen10230a7c10a2461bba6e728cac5287df: pid=2379 uid=10066 gids={50066, 1028}
> I/dalvikvm( 2379): Turning on JNI app bug workarounds for target SDK version 8...
> I/ActivityThread( 2379): Pub Test_140513_1815.Test_140513_1815.mono.MonoRuntimeProvider.__mono_init__: mono.MonoRuntimeProvider
> D/dalvikvm( 2379): Trying to load lib /data/app-lib/Test_140513_1815.Test_140513_1815-1/libmonodroid.so 0x413c0ba0
> D/dalvikvm( 2379): Added shared lib /data/app-lib/Test_140513_1815.Test_140513_1815-1/libmonodroid.so 0x413c0ba0
> W/MonoDroid-Debugger( 2379): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=,server=y,embedding=1
> E/MonoDroid-Debugger( 2379): Could not construct a socket for stdout and stderr
> I/ActivityManager(  484): Process Test_140513_1815.Test_140513_1815 (pid 2379) has died.
> D/Zygote  (  126): Process 2366 exited cleanly (3)

What's happening is that the process is being started (corresponding to AndroidTools' `am start` command), and the launched process attempts to connect to the IDE, which fails because the socket couldn't be constructed.

Generally the socket can't be constructed because the app doesn't have INTERNET permission. This is again confirmed if I look at Attachment #3961 [details] 's Test_140513/Test_140513/obj/Debug/android/AndroidManifest.xml, which lacks the INTERNET permission.

INTERNET permission is usually automatically added when Debug symbols are compiled; from Xamarin.Android.Common.targets:

>	<When Condition=" '$(DebugSymbols)' != '' And $(DebugSymbols) And '$(DebugType)' != '' And '$(DebugType)' == 'Full' ">
>		<PropertyGroup>
>			<AndroidIncludeDebugSymbols>True</AndroidIncludeDebugSymbols>
>		</PropertyGroup>
>	</When>

From your .csproj, I see that $(DebugSymbols) is true (yay), but $(DebugType) is not set at all. I believe that _this_ is the actual problem: since $(DebugType) isn't set, we'll consider this to be a "non-Debug" build, the INTERNET permission won't be added, and you won't be able to debug.
Comment 16 Jonathan Pryor 2013-05-14 19:11:53 UTC
This looks to be a redux of Bug #11679, which was never fixed on the stable branch. Curses.

*** This bug has been marked as a duplicate of bug 11679 ***
Comment 17 Philippe Monteil 2013-05-15 02:13:12 UTC
I have installed the latest Xamarin.Studio and .Android
and apps created with both 4.0.5 and 4.0.6 deploy and debug well:
thanks a lof for your quick and effective support!