Skip to content

Conversation

@dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Aug 15, 2017

Context https://bugzilla.xamarin.com/show_bug.cgi?id=58580

Commit edabe8a reworked the build logic so that $(Optimize)
controls the deployment of the debug or release runtimes.

Input Property:                                                      || Output Property
DebugSymbols    | DebugType  | EmbedAssembliesIntoApk   | Optimize   || AndroidIncludeDebugSymbols
================+============+==========================+============++===========================
True              *any*        True                       True          False      (Release runtime)
True              *any*        True                       False         True       (Debug runtime)
True              *any*        False                      True          True       (Debug runtime)
True              *any*        False                      False         True       (Debug runtime)
True              *empty*      True                       True          True       (Debug runtime)
True              *empty*      True                       False         True       (Debug runtime)
True              *empty*      False                      True          True       (Debug runtime)
True              *empty*      False                      False         True       (Debug runtime)
False             -            -                          -             False      (Release runtime)
*empty*           *any*        *empty*                    False         True       (Debug runtime)

In the senario in the bug $(DebugSymols) $(EmbedAssembliesIntoApk) are both empty.
As a result $(EmbedAssembliesIntoApk) gets a default value of 'False'.
But because $(DebugSymols) is empty we fall through the MSBuild case statement
and end up with $(AndroidIncludeDebugSymbols) = True. Which is NOT what we want in this case.
So if $(EmbedAssembliesIntoApk) we should always default $(AndroidIncludeDebugSymbols)
to false.

In addition there was a weird issue with the way we install debug apps.
If the app is using the Shared Runtime the deployment process sends a
broadcast to the Shared Runtime app which returns the external storage
directory. This tends to be something like

/mnt/shell/emulated/0/

So when we deploy our debug assemblies we do so to a directory like

/mnt/shell/emulated/0/Android/data/$(PackageName)/files/.__override__

This works as expected. Now if we try to debug an app without using the Shared
Runtime it will work as expected.. unless the Shared Runtime was not installed.
In this case the broadcast fails and we fall back to getting the external storage
using

adb shell echo -b ${EXTERNAL_STORAGE}

This returns

/mnt/shell/emulated/legacy

so we end up deploying the debug assemblies to

/mnt/shell/emulated/legacy/Android/data/$(PackageName)/files/.__override__

So all is well and good. However problems start in our runtime and the
MonoPackageManager. We use

android.os.Environment.getExternalStorageDirectory ();

to get the external storage directory. In this case it ALWAYS returns

/mnt/shell/emulated/0/

So if we are debugging without the Shared Runtime being installed, we will
NEVER find the fast deployed assebmies. So the app will crash. The fix in
this case is to check both directories when we are running the debug
runtime.

@dellis1972
Copy link
Contributor Author

build

@dellis1972 dellis1972 added the do-not-merge PR should not be merged. label Aug 16, 2017
@dellis1972 dellis1972 force-pushed the Bug58580 branch 3 times, most recently from 33517e8 to 61c5fe3 Compare August 22, 2017 08:53
@dellis1972 dellis1972 removed the do-not-merge PR should not be merged. label Aug 24, 2017
…g certain projects in Release modes which don't have Optimize set to True

Context https://bugzilla.xamarin.com/show_bug.cgi?id=58580

Commit edabe8a reworked the build logic so that `$(Optimize)`
controls the deployment of the debug or release runtimes.

	Input Property:                                                      || Output Property
	DebugSymbols    | DebugType  | EmbedAssembliesIntoApk   | Optimize   || AndroidIncludeDebugSymbols
	================+============+==========================+============++===========================
	True              *any*        True                       True          False      (Release runtime)
	True              *any*        True                       False         True       (Debug runtime)
	True              *any*        False                      True          True       (Debug runtime)
	True              *any*        False                      False         True       (Debug runtime)
	True              *empty*      True                       True          True       (Debug runtime)
	True              *empty*      True                       False         True       (Debug runtime)
	True              *empty*      False                      True          True       (Debug runtime)
	True              *empty*      False                      False         True       (Debug runtime)
	False             -            -                          -             False      (Release runtime)
	*empty*           *any*        *empty*                    False         True       (Debug runtime)

In the senario in the bug `$(DebugSymols)` `$(EmbedAssembliesIntoApk)` are both empty.
As a result `$(EmbedAssembliesIntoApk)` gets a default value of 'False'.
But because `$(DebugSymols)` is empty we fall through the MSBuild case statement
and end up with `$(AndroidIncludeDebugSymbols)` = `True`. Which is NOT what we want in this case.
So if `$(EmbedAssembliesIntoApk)` we should always default `$(AndroidIncludeDebugSymbols)`
to false.

In addition there was a weird issue with the way we install debug apps.
If the app is using the Shared Runtime the deployment process sends a
broadcast to the Shared Runtime app which returns the external storage
directory. This tends to be something like

	/mnt/shell/emulated/0/

So when we deploy our debug assemblies we do so to a directory like

	/mnt/shell/emulated/0/Android/data/$(PackageName)/files/.__override__

This works as expected. Now if we try to debug an app without using the Shared
Runtime it will work as expected.. unless the Shared Runtime was not installed.
In this case the broadcast fails and we fall back to getting the external storage
using

	adb shell echo -b ${EXTERNAL_STORAGE}

This returns

	/mnt/shell/emulated/legacy

so we end up deploying the debug assemblies to

	/mnt/shell/emulated/legacy/Android/data/$(PackageName)/files/.__override__

So all is well and good. However problems start in our runtime and the
MonoPackageManager. We use

	android.os.Environment.getExternalStorageDirectory ();

to get the external storage directory. In this case it ALWAYS returns

	/mnt/shell/emulated/0/

So if we are debugging without the Shared Runtime being installed, we will
NEVER find the fast deployed assebmies. So the app will crash. The fix in
this case is to check both directories when we are running the debug
runtime.
@dellis1972
Copy link
Contributor Author

build

@jonpryor jonpryor merged commit ff28d57 into dotnet:master Aug 29, 2017
jonpryor pushed a commit to jonpryor/xamarin-android that referenced this pull request Sep 11, 2017
dotnet#749)

Context: https://bugzilla.xamarin.com/show_bug.cgi?id=58580

Unable to locate assemblies when running projects when
`$(Configuration)`=Release and `$(Optimize)` != True.

Commit edabe8a reworked the build logic so that `$(Optimize)`
controls the deployment of the debug or release runtimes.

	Input Property:                                                      || Output Property
	DebugSymbols    | DebugType  | EmbedAssembliesIntoApk   | Optimize   || AndroidIncludeDebugSymbols
	================+============+==========================+============++===========================
	True              *any*        True                       True          False      (Release runtime)
	True              *any*        True                       False         True       (Debug runtime)
	True              *any*        False                      True          True       (Debug runtime)
	True              *any*        False                      False         True       (Debug runtime)
	True              *empty*      True                       True          True       (Debug runtime)
	True              *empty*      True                       False         True       (Debug runtime)
	True              *empty*      False                      True          True       (Debug runtime)
	True              *empty*      False                      False         True       (Debug runtime)
	False             -            -                          -             False      (Release runtime)
	*empty*           *any*        *empty*                    False         True       (Debug runtime)

In this scenario, `$(DebugSymols)` and `$(EmbedAssembliesIntoApk)` are both empty.
As a result `$(EmbedAssembliesIntoApk)` gets a default value of 'False'.
But because `$(DebugSymols)` is empty we fall through the MSBuild case statement
and end up with `$(AndroidIncludeDebugSymbols)` = `True`. Which is NOT what we want in this case.
So if `$(EmbedAssembliesIntoApk)` we should always default `$(AndroidIncludeDebugSymbols)`
to false.

In addition there was a weird issue with the way we install debug apps.
If the app is using the Shared Runtime the deployment process sends a
broadcast to the Shared Runtime app which returns the external storage
directory. This tends to be something like

	/mnt/shell/emulated/0/

So when we deploy our debug assemblies we do so to a directory like

	/mnt/shell/emulated/0/Android/data/$(PackageName)/files/.__override__

This works as expected. Now if we try to debug an app without using the Shared
Runtime it will work as expected.. unless the Shared Runtime was not installed.
In this case the broadcast fails and we fall back to getting the external storage
using

	adb shell echo -b ${EXTERNAL_STORAGE}

This returns

	/mnt/shell/emulated/legacy

so we end up deploying the debug assemblies to

	/mnt/shell/emulated/legacy/Android/data/$(PackageName)/files/.__override__

So all is well and good. However problems start in our runtime and the
MonoPackageManager. We use

	android.os.Environment.getExternalStorageDirectory ();

to get the external storage directory. In this case it ALWAYS returns

	/mnt/shell/emulated/0/

So if we are debugging without the Shared Runtime being installed, we will
NEVER find the fast deployed assebmies. So the app will crash. The fix in
this case is to check both directories when we are running the debug
runtime.
@github-actions github-actions bot locked and limited conversation to collaborators Feb 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants