Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .external
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
xamarin/monodroid:master@1ac5333ec5e90b4e1fb9b324714811effdede37f
xamarin/monodroid:master@767f647151936303c294d154d0d0a4da8b601464
mono/mono:2020-02@be2226b5a1c57df065efc4c1cf008d581e5cec7d
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"bin/TestDebug/MSBuildDeviceIntegration/MSBuildDeviceIntegration.dll",
"bin/TestDebug/net472/Xamarin.Android.Build.Tests.dll",
"bin/TestDebug/Xamarin.Android.Build.Tests.Commercial.dll",
"bin/TestRelease/MSBuildDeviceIntegration/MSBuildDeviceIntegration.dll",
],
"cmake.configureOnOpen": false
}
43 changes: 20 additions & 23 deletions Documentation/guides/building-apps/build-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,35 @@ In broad terms, there are two types of Android application packages
Not coincidentally, these match the MSBuild `Configuration` which
produces the package.

## Shared Runtime

The *shared runtime* is a pair of additional Android packages which
provide the Base Class Library (`mscorlib.dll`, etc.) and the
Android binding library (`Mono.Android.dll`, etc.). Debug builds
rely upon the shared runtime in lieu of including the Base Class Library and
Binding assemblies within the Android application package, allowing the
Debug package to be smaller.

The shared runtime may be disabled in Debug builds by setting the
[`$(AndroidUseSharedRuntime)`](~/android/deploy-test/building-apps/build-properties.md#androidusesharedruntime)
property to `False`.

<a name="Fast_Deployment"></a>

## Fast Deployment

*Fast deployment* works in concert with the shared runtime to further
shrink the Android application package size. This is done by not
bundling the app's assemblies within the package. Instead, they are
copied onto the target via `adb push`. This process speeds up the
build/deploy/debug cycle because if *only* assemblies are changed,
the package is not reinstalled. Instead, only the updated assemblies are
re-synchronized to the target device.
*Fast deployment* works by further shrinking Android application
package size. This is done by not bundling the app's assemblies
within the package. Instead, the are deployed directly to the
application internal `files` directory. This is usually located
in `/data/data/com.some.package`. This is not a global writable
folder, so we need to use the `run-as` tool to run all the
commands to copy the files into that diectory.

Fast deployment is known to fail on devices which block `adb` from
synchronizing to the directory
`/data/data/@PACKAGE_NAME@/files/.__override__`.
This process speeds up the build/deploy/debug cycle because
if *only* assemblies are changed, the package is not reinstalled.
Instead, only the updated assemblies are re-synchronized to the
target device.

Fast deployment is known to fail on devices which block `run-as`. This
is usually devices of API 20 and lower.

Fast deployment is enabled by default, and may be disabled in Debug builds
by setting the `$(EmbedAssembliesIntoApk)` property to `True`.

The [Enhanced Fast Deployment](~/android/deploy-test/building-apps/build-properties.md#AndroidFastDeploymentType) mode can
be used in conjunction with this feature to speed up deployments even further.
This will deploy both assemblies, native libraries, typemaps and dexes to the `files`
directory. But you should only really need to enable this if you are changing
native libraries, bindings or Java code.

## MSBuild Projects

The Xamarin.Android build process is based on MSBuild, which is also
Expand Down
22 changes: 8 additions & 14 deletions Documentation/guides/building-apps/build-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ compiler.

Added in Xamarin.Android 10.2.

<a name="AndroidFastDeploymentType"></a>

## AndroidFastDeploymentType

A `:` (colon)-separated list
Expand All @@ -433,12 +435,16 @@ faster.) Valid values include:

- `Assemblies`: Deploy application assemblies.

- `Dexes`: Deploy `.dex` files, Android Resources, and Android
Assets. **This value can *only* be used on devices running
- `Dexes`: Deploy `.dex` files, native libraries and typemaps.
**This value can *only* be used on devices running
Android 4.4 or later (API-19).**

The default value is `Assemblies`.

Support for Fast Deploying resources and assets via that system was
removed in commit [f0d565fe](https://github.com/xamarin/xamarin-android/commit/f0d565fe4833f16df31378c77bbb492ffd2904b9). This was becuase it required the use of
deprecated API's to work.

**Experimental**. Added in Xamarin.Android 6.1.

## AndroidGenerateJniMarshalMethods
Expand Down Expand Up @@ -1003,18 +1009,6 @@ than `aapt`.

Added in Xamarin.Android 8.1.

## AndroidUseSharedRuntime

A boolean property that
determines whether the *shared runtime packages* are required in
order to run the Application on the target device. Relying on the
shared runtime packages allows the Application package to be
smaller, speeding up the package creation and deployment process,
resulting in a faster build/deploy/debug turnaround cycle.

This property should be `True` for Debug builds, and `False` for
Release projects.

## AndroidVersionCodePattern

A string property which allows
Expand Down
10 changes: 10 additions & 0 deletions Documentation/guides/messages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ ms.date: 01/24/2020
+ [XA0122](xa0122.md): Assembly '{assembly}' is using a deprecated attribute '[assembly: Java.Interop.DoNotPackageAttribute]'. Use a newer version of this NuGet package or notify the library author.
+ XA0123: Removing {issue} from {propertyName}. Lint {version} does not support this check.
+ [XA0124](xa0124.md): Interpreter is not supported by the x86 ABI
+ [XA0125](xa0125.md): `{Project}` is using a deprecated debug information level.
Set the debugging information to Portable in the Visual Studio project property pages or edit the project file in a text editor and set the 'DebugType' MSBuild property to 'portable' to use the newer, cross-platform debug information level.
If this file comes from a NuGet package, update to a newer version of the NuGet package or notify the library author.
+ [XA0126](xa0126.md): Error installing FastDev Tools. This device does not support Fast Deployment. Please rebuild your app using `EmbedAssembliesIntoApk = True`.
+ [XA0127](xa0127.md): There was an issue deploying {destination} using {FastDevTool}. We encountered the following error {output}. Please rebuild your app using `EmbedAssembliesIntoApk = True`.
+ [XA0128](xa0128.md): Stdio Redirection is enabled. Please disable it to use Fast Deployment.
+ [XA0129](xa0129.md): Error deploying `{File}`. Please disable fast deployment in the Visual Studio project property pages or edit the project file in a text editor and set the 'EmbedAssembliesIntoApk' MSBuild property to 'true'.
+ [XA0130](xa0130.md): Sorry. Fast deployment is only supported on devices running Android 5.0 (API level 21) or higher.
Please disable fast deployment in the Visual Studio project property pages or edit the project file in a text editor and set the 'EmbedAssembliesIntoApk' MSBuild property to 'true'.

## XA1xxx: Project related

Expand Down Expand Up @@ -233,6 +242,7 @@ and `NNN` is a 3 digit number indicating the type of the unhandled `Exception`.
* `DES` - `Desugar`
* `DJL` - `DetermineJavaLibrariesToCompile`
* `DX8` - `D8`
* `FD` - `FastDeploy`
* `FLB` - `FindLayoutsToBind`
* `FLT` - `FilterAssemblies`
* `GAD` - `GetAndroidDefineConstants`
Expand Down
2 changes: 0 additions & 2 deletions Documentation/guides/messages/xa0119.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ Remove the following options from `Debug` configurations:

* `<AndroidLinkMode>None</AndroidLinkMode>`
* `<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>`
* `<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>`

*DO* use the following options for `Release` configurations:

* `<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>`
* `<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>`

Consider submitting a [bug][bug] if you are getting one of these
warnings under normal circumstances.
Expand Down
20 changes: 20 additions & 0 deletions Documentation/guides/messages/xa0126.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Xamarin.Android error XA0126
description: XA0126 error code
ms.date: 08/07/2020
---
# Xamarin.Android error XA0126

## Issue

This issue happens when you are trying to use fast deployment on a device which
does not support it. Fast deployment requires features which are not available
on devices running API 20 or lower. The Fast Deployment system makes use of the
[`run-as`](https://android.googlesource.com/platform/system/core.git/+/refs/heads/master/run-as/run-as.cpp#42) feature of the Android OS. This feature was either not available or had
limited capabilities in API 20 and earlier.

## Solution

Disable Fast Deployment by setting `EmbedAssembliesIntoApk = True` in your .csproj.
Or turn off `Fast Deployment` in the IDE. You will still be able to debug on the device,
all the required files will be packaged inside the .apk.
19 changes: 19 additions & 0 deletions Documentation/guides/messages/xa0127.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Xamarin.Android error XA0127
description: XA0127 error code
ms.date: 08/07/2020
---
# Xamarin.Android error XA0127

## Issue

If you encounter this issue something unexpected happened with the Fast Deployment
native tooling. This is most likely to be a native crash.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an example error message would be good here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never managed to get it to crash so I'm not sure lol


## Solution

To work around the issue disable Fast Deployment by setting `EmbedAssembliesIntoApk = True`
in your .csproj. Or turn off `Fast Deployment` in the IDE. You will still be able to debug
on the device, all the required files will be packaged inside the .apk.

In addition raise an issue at [https://github.com/xamarin/xamarin-android/issues/new/choose](https://github.com/xamarin/xamarin-android/issues/new/choose). Please provide the deployment log and as much detail as possible.
26 changes: 26 additions & 0 deletions Documentation/guides/messages/xa0128.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Xamarin.Android error XA0128
description: XA0128 error code
ms.date: 08/07/2020
---
# Xamarin.Android error XA0128

## Issue

The Fast Deployment system relys on reading the output from the various system applications
on the device. This is done by reading `System.out`, which by default is where all output
will be redirected. If `log.redirect-stdio` this will cause all of the Fast Deployment tooling
to fail.

## Solution

Disable the redirection of stdio in order to use Fast Deployment. This can be done using
the following commands.

```
adb shell stop
adb shell setprop log.redirect-stdio false
adb shell start
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to use @(AndroidEnvironment) to do this? It might be easier for users if it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really. Because on devices you need to run this as root. So it needs to be run by the user.
To be honest, I've never seen anyone report this issue so I'm not sure if anyone actually changes the android log.redirect-stdio property.

```

Depending on the device you might need to run `adb root` before running the above commands.
19 changes: 19 additions & 0 deletions Documentation/guides/messages/xa0129.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
title: Xamarin.Android error XA0129
description: XA0129 error code
ms.date: 08/07/2020
---
# Xamarin.Android error XA0129

## Issue

This issue happens when you are trying to use fast deployment on a device which
does not support it. In this case both the normal and backup types of fast
deployment failed. The Fast Deployment system makes use of the
[`run-as`](https://android.googlesource.com/platform/system/core.git/+/refs/heads/master/run-as/run-as.cpp#42) feature of the Android OS. This feature was either not available or had
limited capabilities in API 20 and earlier

## Solution

Disable Fast Deployment by setting `EmbedAssembliesIntoApk = True` in your .csproj.
Or turn off `Fast Deployment` in the IDE. You will still be able to debug on the device,
all the required files will be packaged inside the .apk.
19 changes: 19 additions & 0 deletions Documentation/guides/messages/xa0130.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
title: Xamarin.Android error XA0130
description: XA013- error code
ms.date: 08/07/2020
---
# Xamarin.Android error XA0130

## Issue

This issue happens when you are trying to use fast deployment on a device which
does not support it. Fast deployment requires features which are not available
on devices running API 20 or lower. The Fast Deployment system makes use of the
[`run-as`](https://android.googlesource.com/platform/system/core.git/+/refs/heads/master/run-as/run-as.cpp#42) feature of the Android OS. This feature was either not available or had
limited capabilities in API 20 and earlier.

## Solution

Disable Fast Deployment by setting `EmbedAssembliesIntoApk = True` in your .csproj.
Or turn off `Fast Deployment` in the IDE. You will still be able to debug on the device,
all the required files will be packaged inside the .apk.
17 changes: 17 additions & 0 deletions Documentation/release-notes/4690.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Fast Deployment Updates.

As part of this update the fast deplyment system used for Debugging apps has
been changed. The shared runtime is now no longer used or required.
The Platform package has also been make obsolete.

The new system also no longer uses the `external` drive for the fast deployment
files. All of the files and tooling are now stored in the applications' `internal`
directory. This has an advantage in that when the application is uninstalled all
if the files and the tooling will be removed as well.

The new system will not work on any devices older than API 21. This is because it
relys on features that only work from API 21 onwards. Also API 21 is the lowest
supported platform for the runtime, so running and debugging on older devices will
be impossible.

See [Documentation](~/android/deploy-test/building-apps/build-process.md#FastDeployment) for more details.
6 changes: 5 additions & 1 deletion build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<LibExtension Condition=" '$(HostOS)' == 'Windows' ">dll</LibExtension>
<IncludeMonoBundleComponents Condition="'$(IncludeMonoBundleComponents)' == ''">True</IncludeMonoBundleComponents>
<UseCommercialInstallerName Condition="'$(UseCommercialInstallerName)' == ''">False</UseCommercialInstallerName>
<_HasCommercialFiles Condition="Exists('$(MSBuildSrcDir)\Mono.Android.DebugRuntime-debug.apk')">True</_HasCommercialFiles>
<_HasCommercialFiles Condition="Exists('$(MSBuildSrcDir)\Xamarin.Android.Common.Debugging.targets')">True</_HasCommercialFiles>
</PropertyGroup>
<ItemGroup>
<_MsxDocAssembly Include="Mono.Android">
Expand Down Expand Up @@ -421,6 +421,10 @@
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Installer.Common.dll" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Installer.Common.pdb" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Installer.Common.targets" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\K4os.Compression.LZ4.dll" />
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MSBuildSrcDir)\lib\%(Identity)\xamarin.sync')" />
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MSBuildSrcDir)\lib\%(Identity)\xamarin.find')" />
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MSBuildSrcDir)\lib\%(Identity)\xamarin.stat')" />
<LegacyTargetsFiles Include="$(RootBuildDir)\lib\xamarin.android\xbuild\Novell\Xamarin.Android.Bindings.targets" />
<LegacyTargetsFiles Include="$(RootBuildDir)\lib\xamarin.android\xbuild\Novell\Xamarin.Android.VisualBasic.targets" />
</ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions samples/HelloWorld/HelloLibrary/HelloLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Bundle|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Bundle\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
</PropertyGroup>
<ItemGroup>
Expand All @@ -60,7 +58,7 @@
<Compile Include="LibraryActivity.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
Expand Down
1 change: 0 additions & 1 deletion samples/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ public boolean onCreate ()
@Override
public void attachInfo (android.content.Context context, android.content.pm.ProviderInfo info)
{
String incrementalDeploymentDir = new File (
android.os.Environment.getExternalStorageDirectory (),
"Android/data/" + context.getPackageName ()).getAbsolutePath ();
incrementalDeploymentDir = new File (incrementalDeploymentDir).exists ()
? incrementalDeploymentDir + "/files/"
: context.getFilesDir () + "/";
String incrementalDeploymentDir = context.getFilesDir () + "/";

File codeCacheDir = context.getCacheDir ();
String nativeLibDir = context.getApplicationInfo ().nativeLibraryDir;
Expand Down
1 change: 0 additions & 1 deletion src/Mono.Android/Test/Mono.Android-Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<AssemblyName>Mono.Android-Tests</AssemblyName>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<MandroidI18n>All</MandroidI18n>
<SignAssembly>true</SignAssembly>
Expand Down
1 change: 0 additions & 1 deletion src/OpenTK-1.0/OpenTK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<AssemblyName>OpenTK-1.0</AssemblyName>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<DefineConstants>MONODROID;MINIMAL;MOBILE;OPENTK_1;OPENTK_1_0</DefineConstants>
<NoWarn>3001,3002,3003,3005,3006,3021,3014,0618,1591,0414,0169,0419,1570,1572,1573,1635</NoWarn>
<NoStdLib>true</NoStdLib>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ Copyright (C) 2016 Xamarin. All rights reserved.
TypemapOutputDirectory="$(_NativeAssemblySourceDir)"
GenerateNativeAssembly="false"
MergedAndroidManifestOutput="$(_ManifestOutput)"
UseSharedRuntime="$(AndroidUseSharedRuntime)"
EmbedAssemblies="$(EmbedAssembliesIntoApk)"
BundledWearApplicationName="$(BundledWearApplicationPackageName)"
PackageNamingPolicy="$(AndroidPackageNamingPolicy)"
Expand Down Expand Up @@ -122,7 +121,6 @@ Copyright (C) 2016 Xamarin. All rights reserved.
MainAssembly="$(MonoAndroidLinkerInputDir)$(TargetFileName)"
OutputDirectory="$(_AndroidIntermediateJavaSourceDirectory)mono"
EnvironmentOutputDirectory="$(_AndroidIntermediateJavaSourceDirectory)mono\android\app"
UseSharedRuntime="$(AndroidUseSharedRuntime)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
Manifest="$(IntermediateOutputPath)android\AndroidManifest.xml"
Environments="@(AndroidEnvironment);@(LibraryEnvironments)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This file is only used by "legacy" Xamarin.Android projects.
Value="AndroidKeyStore=True;AndroidSigningKeyStore=$([System.IO.Path]::GetFullPath ('$(AndroidSigningKeyStore)'));AndroidSigningStorePass=$(AndroidSigningStorePass);AndroidSigningKeyAlias=$(AndroidSigningKeyAlias);AndroidSigningKeyPass=$(AndroidSigningKeyPass)">
<Output TaskParameter="Value" PropertyName="_AdditionaEmbeddedWearAppProperties" />
</CreateProperty>
<MSBuild Projects="@(_AppExtensionReference)" Properties="Configuration=$(Configuration);AndroidUseSharedRuntime=False;EmbedAssembliesIntoApk=True;$(_AdditionaEmbeddedWearAppProperties)" Targets="Build;SignAndroidPackage"/>
<MSBuild Projects="@(_AppExtensionReference)" Properties="Configuration=$(Configuration);EmbedAssembliesIntoApk=True;$(_AdditionaEmbeddedWearAppProperties)" Targets="Build;SignAndroidPackage"/>
<CreateProperty
Condition="$(BundledWearApplicationApkPath) == '' And ($(WearAppTarget) == 'SignAndroidPackage' Or !Exists('%(_AppExtensionReference.RootDir)%(_AppExtensionReference.Directory)$(_AndroidDebugKeyStoreFlag)'))"
Value="%(_AppExtensionReference.RootDir)%(_AppExtensionReference.Directory)bin\$(Configuration)\$(BundledWearApplicationPackageName)-Signed.apk">
Expand Down
Loading