Visual Studio : The Android SDK Directory could not be found. Please set via /p:AndroidSdkDirectory
Asked Answered
E

4

13

I have installed Xamarin plugin for Visual Studio 2012.

And when create an Android Project and build the same. I am getting the following error.

Error 1 The Android SDK Directory could not be found. Please set via /p:AndroidSdkDirectory. AndroidApplication1

I think this error is due to some mapping.

Kindly guide to resolve this issue.

Thanks in advance.

Exceptive answered 15/4, 2014 at 8:46 Comment(0)
M
11

You can also set the Android SDK location opening

Tools -> Options -> Xamarin -> Android Settings.

Or you have to re-install Android SDK.

Magnetics answered 7/10, 2016 at 10:1 Comment(0)
R
8

You can solve this by editing the build definition in the VS 2012.

Right click on the Build Definition and Edit Build Definition

Goto Process -> Advanced -> MSBuild Arguments and append the below parameter value to it

/p:AndroidSdkDirectory=C:\android-sdk

it should work.

Roofing answered 18/4, 2014 at 15:20 Comment(2)
Note also that if you're using a TFS build server, the build agent on the server runs in its own account, so the Android SDK and NDKs must be accessible to it. I saw this same error with the SDK/NDK installed in my user account AppData folder, which meant that a local build on the server worked fine, but the TFS build agent couldn't access it and thus failed. After I moved the SDK and NDK to an accessible place, everything worked. Alternately, you can set the account in the TFS admin console > Build Configuration > Build Service properties.Lynnettelynnworth
Also see Xamarin's Configuring TFS page (developer.xamarin.com/guides/cross-platform/ci/configuring_tfs) and also bzbetty.blogspot.com/2014/01/….Lynnettelynnworth
L
3

If you don't have Visual Studio try to set Android SDK path to AndroidSdkDirectory environment variable.

For example I have Android SDK installed in /home/user1/.android-sdk-installer/android-sdk-linux, so I set environment variable like this in terminal:

export AndroidSdkDirectory=/home/user1/.android-sdk-installer/android-sdk-linux

Do not forget that export set environment variables only for current terminal.

Also it's easier to set environment variable once, rather then pass /p:AndroidSdkDirectory every time you want to build.

Levalloisian answered 23/9, 2018 at 10:17 Comment(1)
This strategy also works for windows SET AndroidSdkDirectory=c:\android-sdk or via the widget to set it permanently.Aundreaaunson
S
0

I had the same problem and the solution to this problem for me was to use vpn.since I live in a country where we are under internet boycott using vpn with some patience helped me a lot. With best wishes...

Sanson answered 25/3, 2021 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.