Skip to content

Commit cf9d46a

Browse files
authored
[build] Fix local $(AdbToolPath) (#4842)
Fix "in-tree" usage of `$(AdbToolPath)` for projects which import `Configuration.props`, e.g. > cd samples/HelloWorld > msbuild /t:Install > msbuild /t:StartAndroidActivity … StartAndroidActivity: PackageName: com.xamarin.android.helloworld "…/android-toolchain/sdk/platform-toolsadb" shell am start -n "com.xamarin.android.helloworld/example.MainActivity" /var/folders/j4/t8z2dw2d7pndmvwcxz71njf40000gn/T/tmp04a537baf06445baa371ef57689ad833.exec.cmd: line 2: …/android-toolchain/sdk/platform-toolsadb: No such file or directory …/Xamarin.Android.Application.targets(27,5): error MSB3073: The command ""…/android-toolchain/sdk/platform-toolsadb" shell am start -n "com.xamarin.android.helloworld/example.MainActivity"" exited with code 127. Done Building Project "…/xamarin-android/samples/HelloWorld/HelloWorld.csproj" (StartAndroidActivity target(s)) -- FAILED. The problem is that a directory separator character is missing: what *is* `…/platform-toolsadb` *should be* `…/platform-tools/adb`. The cause is because the default value for `$(AdbToolPath)` within `Configuration.props` packs a trailing `\`. Fix the default value, and the `StartAndroidActivity` target works as intended. Additionally, update `Xamarin.Android.Common.targets` and other projects so that they consistently use `$(AdbToolPath)adb`, instead of a mix of `$(AdbToolPath)adb` *and* `$(AdbToolPath)\adb`, as the latter will hide such issues.
1 parent 28dbfe4 commit cf9d46a

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Configuration.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<ProGuardSourceFullPath>$([System.IO.Path]::GetFullPath ('$(ProGuardSourceDirectory)'))</ProGuardSourceFullPath>
134134
</PropertyGroup>
135135
<PropertyGroup>
136-
<AdbToolPath Condition=" '$(AdbToolPath)' == '' ">$(AndroidSdkFullPath)\platform-tools</AdbToolPath>
136+
<AdbToolPath Condition=" '$(AdbToolPath)' == '' ">$(AndroidSdkFullPath)\platform-tools\</AdbToolPath>
137137
<AdbToolExe Condition=" '$(AdbToolExe)' == '' ">adb</AdbToolExe>
138138
<AvdManagerToolExe Condition=" '$(AvdManagerToolExe)' == '' ">avdmanager</AvdManagerToolExe>
139139
<AndroidToolPath Condition=" '$(AndroidToolPath)' == '' ">$(AndroidSdkFullPath)\tools</AndroidToolPath>

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,7 +2771,7 @@ because xbuild doesn't support framework reference assemblies.
27712771
<Target Name="_DeployApk"
27722772
Condition=" '$(AndroidPackageFormat)' != 'aab' ">
27732773
<PropertyGroup>
2774-
<_DeployCommand>&quot;$(AdbToolPath)\adb&quot; $(AdbTarget) install -r &quot;$(ApkFileSigned)&quot;</_DeployCommand>
2774+
<_DeployCommand>&quot;$(AdbToolPath)adb&quot; $(AdbTarget) install -r &quot;$(ApkFileSigned)&quot;</_DeployCommand>
27752775
</PropertyGroup>
27762776
<Exec
27772777
ContinueOnError="True"
@@ -2825,7 +2825,7 @@ because xbuild doesn't support framework reference assemblies.
28252825
</Target>
28262826

28272827
<Target Name="_Uninstall">
2828-
<Exec Command="&quot;$(AdbToolPath)\adb&quot; $(AdbTarget) uninstall $(_AndroidPackage)" />
2828+
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) uninstall $(_AndroidPackage)" />
28292829
</Target>
28302830

28312831
<Target Name="Uninstall"

tests/BCL-Tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<Import Project="..\..\..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\..\..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets')" />
122122

123123
<Target Name="_GrantPermissions">
124-
<Exec Command="&quot;$(AdbToolPath)\adb&quot; $(AdbTarget) shell pm grant %(TestApkPermission.Package) android.permission.%(TestApkPermission.Identity)" />
124+
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) shell pm grant %(TestApkPermission.Package) android.permission.%(TestApkPermission.Identity)" />
125125
</Target>
126126

127127
<PropertyGroup>

tests/EmbeddedDSOs/EmbeddedDSO/EmbeddedDSO.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<Import Project="$(RelativeRootPath)\build-tools\scripts\TestApks.targets" />
108108

109109
<Target Name="_GrantPermissions">
110-
<Exec Command="&quot;$(AdbToolPath)\adb&quot; $(AdbTarget) shell pm grant %(TestApkPermission.Package) android.permission.%(TestApkPermission.Identity)" />
110+
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) shell pm grant %(TestApkPermission.Package) android.permission.%(TestApkPermission.Identity)" />
111111
</Target>
112112

113113
<PropertyGroup>

0 commit comments

Comments
 (0)