Radinator
Radinator

Reputation: 1088

How to change SDK Build tools path in VS2015 using Xamarin.Adroid

According to serveral blogs, using SDK Build Tools version 24 (link) can cause/causes some weired errors. Now my question is: How can I define WHICH path to the build tools should be used?

In Android Studio, Gradle is used to build the app. Here I can modify the build.gradle file and define the version of build tools that should be used. But when doing the same with VS, it always takes the least version of the tools. So is there a way to tell VS to use a specific path or tell VS to use a certain version like gradle does?

Thanks in advance!

Upvotes: 0

Views: 1596

Answers (1)

Elvis Xia - MSFT
Elvis Xia - MSFT

Reputation: 10841

Referring to Build Process of Xamarin.Android, you can find a setting named AndroidSdkBuildToolsVersion:

The Android SDK build-tools package provides the aapt and zipalign tools, among others. Multiple different versions of the build-tools package may be installed simultaneously. The build-tools package chosen for packaging is done by checking for and using a "preferred" build-tools version if it is present; if the "preferred" version is not present, then the highested versioned installed build-tools package is used.

The $(AndroidSdkBuildToolsVersion) MSBuild property contains the prefered build-tools version. The Xamarin.Android build system provides a default value in Xamarin.Android.Common.targets, and the default value may be overridden within youur project file to choose an alternate build-tools version, if (for example) the latest aapt is crashing out while a previous aapt version is known to work.

So, you can change the build-tool version by adding an AndroidSdkBuildToolsVersion tag under each PropertyGroup of YourProject.csproj file like below:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>True</DebugSymbols>
    <DebugType>Full</DebugType>
    <Optimize>False</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
    <AndroidLinkMode>None</AndroidLinkMode>
    <EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
    <AndroidSdkBuildToolsVersion>24.0.3</AndroidSdkBuildToolsVersion>
  </PropertyGroup>

Upvotes: 2

Related Questions