Bug 115 - Compiling my app in Release mode and nothing works anymore
Summary: Compiling my app in Release mode and nothing works anymore
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 1.0
Hardware: PC Windows
: --- critical
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2011-07-29 17:30 UTC by Stéphane Lavirotte
Modified: 2011-07-31 13:58 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 Stéphane Lavirotte 2011-07-29 17:30:32 UTC
I've got an application completly functional when it is compiled in Debug mode. 
But when I compile it in Release mode, nothing works anymore. I've got a screen with the app title and it closes.
When I go to the list of processes, I don't see anything about my application.

As I'm a MonoDroid customer (I bought a licence some days ago), I would like to know if it's possible to compile my app in Release mode to have better performances.

Thanks in advance.

Stéphane Lavirotte
Comment 1 Jonathan Pobst 2011-07-30 10:53:54 UTC
When you compile in Release mode, you are turning on linking to produce smaller distribution packages:


You will need to figure out which parts are getting removed that should not be removed, and take one of the steps to preserve that code.
Comment 2 Stéphane Lavirotte 2011-07-31 03:35:38 UTC
Thanks for your quick answer. I've learned some important points about MonoDroid.

But, unfortunately, even if I a select the "Don't Link" for all the projects of my solution, I still have the same problem. (the apk if 16Mo instead of 6Mo about)

Here is some information about my project WComp. This is a research project for building dynamic applications for Ambiant Computing. We have a container, containing software components, and a UPnP service is attached to this container. All our code is functional under .NET, running with Microsoft .NET and also with mono on a GNU/Linux ARM platform (Phidget 1072 platform). We would like to have the same application on Android with the help of MonoDroid.

The problem comes at a early stage of the application start. When creating the container, all is ok, except the start of the UPnP service associated to the container (see log). In fact, it seems that there is a problem with System.Net.Dns.GetHostByName. 
My problem is that there is no problem in "Debug" mode on Android, just when I compile in Release mode. And the same code is ok on Windows or embedded Linux with mono in Debug or Release of course.

Here is the trace of an execution. My app is AndroidWComp (16478):

07-31 09:17:43.692 I/ActivityManager( 1328): Starting activity: Intent { act=and
roid.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cm
p=WComp.Container/wcomp.container.Container } from pid 1569
07-31 09:17:43.732 V/HtcAppUsageStats( 1328): (launch app, package): (WComp, WCo
07-31 09:17:43.732 I/[POST_RESELECT]( 1569): [spanChange] (o, oldStart, newStart
, oldEnd, newEnd)=(android.text.Selection$START@40133468,-1,0,-1,0)
07-31 09:17:43.732 I/[POST_RESELECT]( 1569): [spanChange] (o, oldStart, newStart
, oldEnd, newEnd)=(android.text.Selection$END@401387e8,-1,0,-1,0)
07-31 09:17:43.742 D/PhoneWindow( 1569): couldn't save which view has focus beca
use the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@4056
dc38 has no id.
07-31 09:17:43.742 D/Background traffic light( 1569): traffic light: GREEN, mBac
kgroundTrafficLight = true
07-31 09:17:43.772 I/ActivityManager( 1328): Start proc WComp.Container for acti
vity WComp.Container/wcomp.container.Container: pid=16478 uid=10149 gids={}
07-31 09:17:43.852 I/ActivityThread(16478): Pub WComp.Container.__mono_init__: m
07-31 09:17:43.852 D/dalvikvm(16478): Trying to load lib /data/data/WComp.Contai
ner/lib/libmonodroid.so 0x4051bd98
07-31 09:17:43.862 D/dalvikvm(16478): Added shared lib /data/data/WComp.Containe
r/lib/libmonodroid.so 0x4051bd98
07-31 09:17:43.862 I/MonoDroid-Debugger(16478): Not starting the debugger as the
 timeout value has been reached; current-time: 1312096663  timeout: 1312096263
07-31 09:17:43.982 W/dalvikvm( 1569): disableGcForExternalAlloc: false
07-31 09:17:44.002 W/dalvikvm( 1569): disableGcForExternalAlloc: false
07-31 09:17:44.502 D/dalvikvm(16478): GC_CONCURRENT freed 397K, 50% free 2823K/5
639K, external 0K/0K, paused 2ms+2ms
07-31 09:17:44.652 D/dalvikvm(16478): GC_CONCURRENT freed 417K, 50% free 2967K/5
831K, external 0K/0K, paused 2ms+2ms
07-31 09:17:44.792 D/dalvikvm(16478): GC_CONCURRENT freed 423K, 49% free 3087K/5
959K, external 0K/0K, paused 1ms+2ms
07-31 09:17:45.532 I/wpa_supplicant( 3125): Reset vh_switch_counter due to recei
07-31 09:17:45.532 D/ConnectivityService( 1328): getMobileDataEnabled returning
07-31 09:17:45.782 I/AndroidWComp(16478): OnCreate()
07-31 09:17:45.882 D/dalvikvm(16478): GC_EXTERNAL_ALLOC freed 294K, 47% free 318
5K/5959K, external 0K/0K, paused 31ms
07-31 09:17:45.962 D/AndroidWComp(16478): Start container...
07-31 09:17:46.262 I/MonoDroid(16478): UNHANDLED EXCEPTION: System.Net.Sockets.S
ocketException: No such host is known
07-31 09:17:46.262 I/MonoDroid(16478): at System.Net.Dns.hostent_to_IPHostEntry
(string,string[],string[]) <0x002e0>
07-31 09:17:46.262 I/MonoDroid(16478): at System.Net.Dns.GetHostByName (string)
07-31 09:17:46.262 I/MonoDroid(16478): at System.Net.Dns.GetHostEntry (string) <
07-31 09:17:46.262 I/MonoDroid(16478): at OpenSource.UPnP.NetworkInfo..ctor (Ope
nSource.UPnP.NetworkInfo/InterfaceHandler) <0x001e7>
07-31 09:17:46.262 I/MonoDroid(16478): at OpenSource.UPnP.NetworkInfo..ctor () <
07-31 09:17:46.262 I/MonoDroid(16478): at OpenSource.UPnP.SSDP..ctor (int) <0x00
07-31 09:17:46.262 I/MonoDroid(16478): at OpenSource.UPnP.UPnPDevice..ctor (int,
double,string) <0x0042f>
07-31 09:17:46.262 I/MonoDroid(16478): at OpenSource.UPnP.UPnPDevice.CreateRootD
evice (int,double,string) <0x00057>
07-31 09:17:46.262 I/MonoDroid(16478): at WComp.UPnPDesignComponent.WCompNetCont
rolDevice..ctor (string,WComp.ApplicationArchitecture.DesignerInterface) <0x0006
07-31 09:17:46.262 I/MonoDroid(16478): at WComp.UPnPDesignComponent.WCompNetDevi
ce..ctor (string,WComp.ApplicationArchitecture.DesignerInterface) <0x0002f>
07-31 09:17:46.262 I/MonoDroid(16478): at WComp.Container.Container.Start () <0x
07-31 09:17:46.262 I/MonoDroid(16478): at WComp.Container.Container.OnCreate (An
droid.OS.Bundle) <0x0015b>
07-31 09:17:46.262 I/MonoDroid(16478): at Android.App.Activity.n_OnCreate_Landro
id_os_Bundle_ (intptr,intptr,intptr) <0x00057>
07-31 09:17:46.262 I/MonoDroid(16478): at (wrapper dynamic-method) object.97c6f7
09-86ed-4aa2-8d38-0776f9ba3c3c (intptr,intptr,intptr) <0x00033>
07-31 09:17:46.312 E/mono    (16478):
07-31 09:17:46.312 E/mono    (16478): Unhandled Exception: System.Net.Sockets.So
cketException: No such host is known
07-31 09:17:46.312 E/mono    (16478):   at System.Net.Dns.hostent_to_IPHostEntry
 (System.String h_name, System.String[] h_aliases, System.String[] h_addrlist) [
0x00000] in <filename unknown>:0
07-31 09:17:46.312 E/mono    (16478):   at System.Net.Dns.GetHostByName (System.
String hostName) [0x00000] in <filename unknown>:0
07-31 09:17:46.312 E/mono    (16478):   at System.Net.Dns.GetHostEntry (System.S
tring hostNameOrAddress) [0x00000] in <filename unknown>:0
07-31 09:17:46.312 E/mono    (16478):   at OpenSource.UPnP.NetworkInfo..ctor (Op
enSource.UPnP.InterfaceHandler onNewInterfaceSink) [0x00000] in <filename unknow
07-31 09:17:46.312 E/mono    (16478):   at OpenSource.UPnP.NetworkInfo..ctor ()
[0x00000] in <filename unknown>:0
07-31 09:17:46.312 E/mono    (16478):   at OpenSource.UPnP.SSDP..ctor (Int32 Exp
iration) [0x00000] in <filename unknown>:0
07-31 09:17:46.312 E/mono    (16478):   at OpenSource.UPnP.UPnPDevice..ctor (Int
32 DeviceExpiration, Double version, System.String RootDir) [0x00000] in <filena
me unknown>:0
07-31 09:17:46.312 E/mono    (16478):   at OpenSource.UPnP.UPnPDevice.CreateRoot
Device (Int32 DeviceExpiration, Double version, System.String RootDir) [0x00000]
 in <filename unknown>:0
07-31 09:17:46.312 E/mono    (16478):   at WComp.UPnP
07-31 09:17:46.332 I/ActivityManager( 1328): Process WComp.Container (pid 16478)
 has died.
07-31 09:17:46.332 E/ActivityManager( 1328): fail to set top app changed!
07-31 09:17:46.332 D/Zygote  ( 1235): Process 16478 exited cleanly (1)
07-31 09:17:46.352 D/Sensors ( 1328): Enable akm: en = 0
07-31 09:17:46.352 D/SensorService( 1328): noteStopSensor: uid = 0x3e8, handle =

As I select "Don't Link" for all the projects and assuming that this code is correct and functional when I compile it under "Debug" directive, I don't see what is the problem on my side.
Do you have any other information to send me ?
Comment 3 Jonathan Pobst 2011-07-31 11:50:01 UTC
Oh, ok.  The other difference between Debug and Release is on Debug builds we automatically add the INTERNET permission to the app because it is required by the debugger.  In Release mode, you need to add this to your app since you are using sockets.

Project Properties -> Android Manifest -> Permissions -> INTERNET.
Comment 4 Stéphane Lavirotte 2011-07-31 13:58:44 UTC
That's it! 
Thank you very much for your help. All is working fine... for the moment ;)