Bug 56075 - android:debuggable="true" should not be set in RELEASE mode
Summary: android:debuggable="true" should not be set in RELEASE mode
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-05-05 22:00 UTC by Ian
Modified: 2017-05-13 10:14 UTC (History)
1 user (show)

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


Attachments
Diagnostic build (419.84 KB, application/x-zip-compressed)
2017-05-11 15:47 UTC, Ian
Details


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:
Status:
RESOLVED ANSWERED

Description Ian 2017-05-05 22:00:20 UTC
Visual Studio 2017, Xamarin SDK 7.2.0.7

My .csProj show that no Debug info should be set:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>false</DebugSymbols>
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>
    </DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
  </PropertyGroup>

My AndroidManifest.xml has no debug info and I don't have debug set in my AssemblyuInfo.cs

    ** THIS IS NOT THERE [assembly: Application(Debuggable = xxxxx

Yet, when I build for release, the /obj/Release/Android/ApplicationManefest.xml has "android:debuggable="true"" set in the Application. 

So of course I can't publish to the Play store.

How do I get Visual Studio 2017 to not put in the android:debuggable="true" into the Release ??
Comment 1 dean.ellis 2017-05-08 08:59:43 UTC
try removing the DebugType element or set it to ''.

You can see the logic that is used at [1].

That said if the IDE or templates is setting that to 'none' by default we will need to handle that case. This might be a recent change in the IDE. I think VS2015 used to leave DebugType blank if it was set to None in the IDE.


[1] https://github.com/xamarin/xamarin-android/blob/master/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets#L267
Comment 2 dean.ellis 2017-05-08 15:07:57 UTC
PS has been put up https://github.com/xamarin/xamarin-android/pull/583
Comment 3 Ian 2017-05-08 15:31:22 UTC
How do I get this fix so that I can build? I have tried every setting I know in the .csproj.

A work around hack would be fine if you have one
Comment 4 dean.ellis 2017-05-09 08:05:30 UTC
Ian

Did you try editing the csproj directly and changing 

<DebugType>none</DebugType>

to 

<DebugType></DebugType>

or even removing it entirely?
Comment 5 Ian 2017-05-09 15:37:04 UTC
I removed all debug information from the .csproj with no effect.

I will attach a project to repeat the issue. Just compile it with RELEASE mode to see the generated AndroidManifest.xml with the Debuggable set to true.
Comment 6 Ian 2017-05-09 18:01:36 UTC
I am unable to attach a solution which shows the error, Bugzilla says I am not permitted. I can email it. Let me know
Comment 7 dean.ellis 2017-05-10 08:53:18 UTC
Did you remove it only from the Release configuration group? 

Hmm.. VS2017 must be setting a default when it calls the build process then.  It might be better to set it to <DebugType></DebugType> rather than removing it in that case.



If that doesn't work the only work around at the moment would be a apply the code changes to your local copy of Xamarin.Android.Common.targets

The changes you need will be https://github.com/xamarin/xamarin-android/pull/583/files#diff-db39bf07b89b50eaab8ab2001546310cR268

The file will be in 

C:\Program Files (x86)\Microsoft Visual Studio\2017\<version>\MSBuild\Xamarin\Android

where <version> will be "Professional" "Enterprise" etc depending on your version.
Comment 8 dean.ellis 2017-05-10 09:24:19 UTC
Can you gist the csproj of your project? We don't need all the files just the csproj.
Comment 9 Ian 2017-05-10 16:01:13 UTC
I have emailed you a copy of the .csproj

I also tried updating the target file and using a blank DebugType but still get a generated AndroidManifest.xml with Debuggable set to True
Comment 10 Ian 2017-05-11 15:47:51 UTC
Created attachment 22089 [details]
Diagnostic build
Comment 11 dean.ellis 2017-05-11 17:11:22 UTC
ok. 

I had a good look at the diagnostic output.

$(AndroidIncludeDebugSymbols) = false

as it should be. So it has nothing to do with the DebugType or DebugSymbols. Something else is causing the AndroidManifest generation/merging to think that debuggable needs to be set to true since you already mention that the Application attribute in assembly info is not being used.

Are you able to attach the packages.config file from the project? My guess is that one of the dependencies has this set in one of the various Manifest files and this gets merged into the main one. That would allow me to restore the exact versions of the packages you use to try to repo.

Also can you attach the project AndroidManifest file and any other AndroidManifest files which might be in your own library projects (there probably aren't any).
Comment 12 Ian 2017-05-11 17:41:21 UTC
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Flurry.Analytics.Portable" version="2.0.0" targetFramework="portable45-net45+win8+wp8" userInstalled="true" />
  <package id="FubarCoder.RestSharp.Portable.Core" version="4.0.8" targetFramework="portable45-net45+win8+wp8" />
  <package id="FubarCoder.RestSharp.Portable.HttpClient" version="4.0.8" targetFramework="portable45-net45+win8+wp8" />
  <package id="Microsoft.Azure.Mobile" version="0.8.1" targetFramework="portable45-net45+win8+wp8" />
  <package id="Microsoft.Azure.Mobile.Analytics" version="0.8.1" targetFramework="portable45-net45+win8+wp8" />
  <package id="Microsoft.Azure.Mobile.Crashes" version="0.8.1" targetFramework="portable45-net45+win8+wp8" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="portable45-net45+win8+wp8" userInstalled="true" />
  <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="portable-monoandroid1+monotouch1+net45+win+wp8+xamarinios1" userInstalled="true" />
  <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="portable45-net45+win8+wp8" userInstalled="true" />
  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="portable45-net45+win8+wp8" userInstalled="true" />
  <package id="Newtonsoft.Json" version="10.0.2" targetFramework="portable45-net45+win8+wp8" />
  <package id="Rx-Core" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Rx-Interfaces" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Rx-Linq" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Rx-Main" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Rx-PlatformServices" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Xam.Plugin.DeviceInfo" version="2.1.2" targetFramework="portable45-net45+win8+wp8" />
  <package id="Xam.Plugins.Settings" version="2.5.4" targetFramework="portable45-net45+win8+wp8" userInstalled="true" />
  <package id="Xamarin.Forms" version="2.3.4.231" targetFramework="portable45-net45+win8+wp8" userInstalled="true" />
  <package id="Xamarin.Insights" version="1.12.3" targetFramework="portable45-net45+win8+wp8" userInstalled="true" />
</packages>



and



<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Flurry.Analytics" version="2.0.0" targetFramework="monoandroid60" />
  <package id="Flurry.Analytics.Portable" version="2.0.0" targetFramework="monoandroid60" />
  <package id="FubarCoder.RestSharp.Portable" version="3.3.0" targetFramework="monoandroid60" />
  <package id="FubarCoder.RestSharp.Portable.Core" version="4.0.8" targetFramework="monoandroid71" />
  <package id="FubarCoder.RestSharp.Portable.HttpClient" version="4.0.8" targetFramework="monoandroid71" />
  <package id="Microsoft.Azure.Mobile" version="0.8.1" targetFramework="monoandroid71" />
  <package id="Microsoft.Azure.Mobile.Analytics" version="0.8.1" targetFramework="monoandroid71" />
  <package id="Microsoft.Azure.Mobile.Crashes" version="0.8.1" targetFramework="monoandroid71" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="monoandroid60" userInstalled="true" />
  <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="monoandroid60" userInstalled="true" />
  <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="monoandroid60" userInstalled="true" />
  <package id="Microsoft.CSharp" version="4.3.0" targetFramework="monoandroid71" />
  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="monoandroid60" userInstalled="true" />
  <package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="monoandroid71" />
  <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="monoandroid71" />
  <package id="NETStandard.Library" version="1.6.1" targetFramework="monoandroid71" />
  <package id="Newtonsoft.Json" version="10.0.2" targetFramework="monoandroid71" />
  <package id="Plugin.CurrentActivity" version="1.0.1" targetFramework="monoandroid71" />
  <package id="Rx-Core" version="2.2.5" targetFramework="monoandroid60" />
  <package id="Rx-Interfaces" version="2.2.5" targetFramework="monoandroid60" />
  <package id="Rx-Linq" version="2.2.5" targetFramework="monoandroid60" />
  <package id="Rx-PlatformServices" version="2.2.5" targetFramework="monoandroid60" />
  <package id="System.AppContext" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Collections" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.ComponentModel.TypeConverter" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Console" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Globalization" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Globalization.Calendars" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.IO" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.IO.Compression" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.IO.FileSystem" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Linq" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Net.Http" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Net.Primitives" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Net.Sockets" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.ObjectModel" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Reflection" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Runtime" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Runtime.Handles" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Runtime.Serialization.Formatters" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Text.Encoding" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Threading" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Threading.Timer" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Xml.XDocument" version="4.3.0" targetFramework="monoandroid71" />
  <package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="monoandroid71" />
  <package id="Xam.Plugin.DeviceInfo" version="2.1.2" targetFramework="monoandroid71" />
  <package id="Xam.Plugins.Settings" version="2.5.4" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Compat" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Core.UI" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Core.Utils" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Design" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Fragment" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Media.Compat" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Transition" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v4" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.AppCompat" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.CardView" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.MediaRouter" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.Palette" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.RecyclerView" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Vector.Drawable" version="25.1.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Build.Download" version="0.4.4" targetFramework="monoandroid71" />
  <package id="Xamarin.Forms" version="2.3.4.231" targetFramework="monoandroid71" userInstalled="true" />
  <package id="Xamarin.Insights" version="1.12.3" targetFramework="monoandroid60" userInstalled="true" />
</packages>
Comment 13 Ian 2017-05-11 17:42:14 UTC
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="xxxxxxxxx" android:versionName="1.12" android:versionCode="12">
	<uses-sdk android:minSdkVersion="21" />
	<application android:label="xxxxxxx" android:hardwareAccelerated="true"></application>
</manifest>
Comment 14 dean.ellis 2017-05-13 10:14:38 UTC
Ian

The problem is in MainApplication.cs You have the following code

#if RELEASE
[Application(Debuggable=false)]
#else
	[Application(Debuggable = true)]
#endif

RELEASE is not defined by default on any .net project in a release configuration. So its better to use

#if !DEBUG
[Application(Debuggable=false)]
#else
	[Application(Debuggable = true)]
#endif

or add RELEASE as define in the release configuration yourself. Personally I would go with the !DEBUG :)