Bug 37422 - Release Build Still Creates ".__override__ " Directory
Summary: Release Build Still Creates ".__override__ " Directory
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 6.0.1 (C6SR1)
Hardware: PC Mac OS
: Highest critical
Target Milestone: C6SR2
Assignee: dean.ellis
Depends on:
Reported: 2016-01-05 20:09 UTC by Jimmy [MSFT]
Modified: 2016-03-03 11:39 UTC (History)
6 users (show)

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

logcat (10.23 KB, text/plain)
2016-01-05 20:09 UTC, Jimmy [MSFT]

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 Jimmy [MSFT] 2016-01-05 20:09:15 UTC
Created attachment 14450 [details]

### Overview

A release build of an Android app will still create a writeable “.__override__” directory in the app’s data directory. According to this post[1], the directory is supposed to be created only for debug builds, _not_ release.

I did some testing and this seems to be a regression in 6.0 and still in the latest alpha build since the issue doesn’t occur in 5.1: https://gist.github.com/jimmgarrido/59f80b59ea742c62091e

[1] https://forums.xamarin.com/discussion/comment/50436/#Comment_50436

### Environment Info
=== Xamarin Studio ===

Version 5.10.1 (build 6)
Installation UUID: 94ce5106-6a72-4691-b34e-cd5857b1db66
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

=== Xamarin.Profiler ===

Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 7322991
Branch: master
Build date: 2015-12-08 16:20:29-0500

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/jimmygarrido/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 22.0.1

Java SDK: /usr
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 510010006
Git revision: 0b60eecdb531933734519c13257d16a780274aab
Build date: 2015-12-04 20:28:20-05
Xamarin addins: 9876fd7c9837977178411ec7375b4352c0a0d6af
Build lane: monodevelop-lion-cycle6-baseline

=== Operating System ===

Mac OS X 10.11.2
Darwin Jimmys-MacBook-Pro.local 15.2.0 Darwin Kernel Version 15.2.0
    Fri Nov 13 19:56:56 PST 2015
    root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
Comment 2 Jonathan Pryor 2016-01-05 22:26:35 UTC
> According to this post[1], the directory is supposed to be created only for debug
> builds, _not_ release.


> I did some testing and this seems to be a regression in 6.0

There's a difference between *log files* saying it's *looking* for a file there, vs. *the directory actually existing*.


1. Create new project (default template).
2. Set Configuration to Release
3. Build + Run

`adb logcat` contains:

> 01-05 16:58:33.098 25736 25736 W monodroid: Trying to load sgen from: /storage/emulated/0/Android/data/scratch.bxc37422/files/.__override__/libmonosgen-2.0.so

i.e. it's *looking* for a file in the `.__override__` directory.


> $ adb shell ls -l /storage/emulated/0/Android/data/scratch.bxc37422/files/.__override__
> /storage/emulated/0/Android/data/scratch.bxc37422/files/.__override__: No such file or directory

The directory doesn't exist.

> $ adb shell ls -l /storage/emulated/0/Android/data/scratch.bxc37422
> /storage/emulated/0/Android/data/scratch.bxc37422: No such file or directory

Nor does an app-specific external storage directory.

That said...

> 01-05 17:18:42.333 29613 29613 W monodroid: Trying to load sgen from: /data/user/0/scratch.bxc37422/files/.__override__/libmonosgen-2.0.so

> $ adb shell ls -a /data/user/0/scratch.bxc37422/files/.__override__

*That* is troubling; there's no error message. It therefore exists.

Additional analysis shows that the Debug runtime is being embedded into the app, which is *not* what should be happening.

Thank you for the report.
Comment 3 Jonathan Pryor 2016-01-05 22:43:49 UTC
Enable diagnostic build output, and see:

>                 Mandroid Task
> ...
>                   Debug: True

That's not good. :-(

The Debug value is $(AndroidUseDebugRuntime).

Rebuild the app with the $(AndroidUseDebugRuntime) property set to False fixes the issue:

$ xbuild /p:Configuration=Release /p:AndroidUseDebugRuntime=False /t:SignAndroidPackage App.csproj

So a "workaround" exists, but it's a workaround that shouldn't be necessary.

The problem is in (either? both?) Xamarin.Android.Common.targets and the App.csproj file.


> 	<AndroidUseDebugRuntime Condition="'$(AndroidUseDebugRuntime)' == '' And '$(AndroidUseSharedRuntime)' == 'False' And '$(EmbedAssembliesIntoApk)' == 'True' And '$(DebugType)' != 'Full'" >False</AndroidUseDebugRuntime>
> 	<AndroidUseDebugRuntime Condition="'$(AndroidUseDebugRuntime)' == ''" >True</AndroidUseDebugRuntime>

The default App.csproj as generated by Xamarin Studio 5.10.1:

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

We can manually walk through the //AndroidUseDebugRuntime/@Condition expression, and see that the first line will *not* be executed, i.e. $(AndroidUseDebugRuntime) will be True (the 2nd line), because $(DebugType) is Full. (Why is $(DebugType) defaulting to True?!)

Is this a recent Xamarin Studio change?
Comment 4 Jonathan Pryor 2016-01-06 14:33:08 UTC
> Is this a recent Xamarin Studio change?

David Karlaš did some exploration, and it doesn't seem that Xamarin Studio has changed behavior here.

He suggests that we also check for '$(DebugSymbols)'=='True' in addition to (instead of?) '$(DebugType)'=='Full'.
Comment 5 dean.ellis 2016-01-18 12:00:07 UTC
Fixed in monodroid/master/532f5db7
Comment 6 Danish Akhtar 2016-03-01 08:54:47 UTC
Reproduce Status
I have reproduced this issue with stable XA 6.0.1-10. Here is the adb logcat for the same: https://gist.github.com/Abhishekk360/b4e1d2d718e023312697

Verify Status 
I have checked this issue with master XA, C6 XA and observed that now, ".__override__ " directory. is not exists in adb logcat, while build and run application in Release mode. Here is the adblogcat: https://gist.github.com/Abhishekk360/6d1e922f162aad67dbdf

Hence closing this issue.
Comment 7 Danish Akhtar 2016-03-03 11:39:46 UTC
Today, I have checked this issue with C6SR2 XA and observed that ".override " directory. is not exists in adb logcat, while build and run application in Release mode. 

Here is the adb logcat: https://gist.github.com/Abhishekk360/ca6368ebf6393801a823

Environment info: https://gist.github.com/Abhishekk360/a5b9b07d6cc082dc8311