35

Bringing up a new PC with Xamarin and VS 2015 Pro I received the following error:

An unexpected error occurred trying to initialize Android Designer. Please verify the Android SDK path and the Java Development Kit path on Tools->Options->Xamarin->Android Settings menu. Please see the logs for more details.

I verified the SDK's are installed correctly. VS didn't generate any kind of Activity Log so I believe the log must lie elsewhere. Anyone know where I can find this log to find out more about what is wrong ?

MikeJ
  • 14,430
  • 21
  • 71
  • 87

8 Answers8

61

I had exactly the same problem described (on a new PC, with a new Visual Studio install) and am 99.9% sure the answer is in how updates are applied. Or, more importantly, how they aren't being applied when you think they are.

  1. Go to Tools | Options | Xamarin | Other, and under Xamarin for Visual Studio Updates, Check now for STABLE updates. Make sure you're running at least 4.2.0.680. You will have to close Visual Studio in the background as the updater is running--it'll warn you. Uninstalling and installing the cross-platform development tools from Visual Studio was not applying this update for me. I had to force the issue.

  2. Now, as mentioned earlier, go to Tools, Android SDK Manager. I noticed my "Android SDK Tools" and "Cross Platform Tools" were out of date and updates were available. I accepted and applied the updates to version 24.4.1. BEAR WITH ME, THIS IS WHERE IT GETS TRICKY--it still didn't work.

  3. Go back to Tools, Android SDK Manager. I immediately noticed that even though I'd just applied the latest update for "Android SDK Tools", (24.4.1), a new version (25.2.2) was now available, along with 17 other updates. I accepted them all.

  4. Bingo. Where I once had the annoying error message and an empty design surface and an empty toolbox with the sad "no usable controls" message, I now have the attached screen snapshot--a design surface where I can see a visual representation of my .axml, and a toolbox from which I can drag and drop controls and they actually show up on my Samsung tablet.

Sorry so verbose. I lost hours on this problem and thought others might appreciate another working solution.enter image description here

markaaronky
  • 1,231
  • 12
  • 29
  • 5
    Ugh. Lame. The Xamarin framework is really not transparent about this at all. -- I had no idea that after everything was all said and updated, I then I had to launch an external tool and update more stuff. -- Thanks, this was really helpful by the way. – BrainSlugs83 Oct 06 '16 at 00:16
  • By the way, how are you able to view your ContentPage's xaml in a designer like that? -- that doesn't seem to be the behavior at all with the latest "Blank Xaml App (Xamarin.Forms.Portable)" project template. – BrainSlugs83 Oct 06 '16 at 00:19
  • I haven't been using the Xamarin Forms templates BrainSlugs83 so I'm not sure what happens there, but the above designer behavior is what I wanted--and had to fight to get--using the Android templates. I got frustrated with the Forms templates because they were including projects for Microsoft devices (and a lot of other fluff) that wouldn't build. I'll be exploring Forms as soon as I can afford to set up an Apple dev environment, but I've been just targeting Android right now--I must confess I am very new to Xamarin by the way – markaaronky Oct 24 '16 at 20:08
  • 1
    Perfect answer + you might have to close Visual Studio if already open or close antivirus program as it might not copy certain folder when they are actively used or opened. – TheTechGuy Nov 08 '16 at 14:24
  • man. My Android SDK Manager just won't open. I had to open it through the tools\android.bat. Any way to fix this so that I can open this on my VS 2015? Also, Intalling xamarin is a pain in the neck, this is my second day just trying to make an error/warning free project. Currently updating it as you mentioned here, hopefully it starts working fine. – Wax Nov 27 '16 at 08:17
  • The above solution didn't work for me, but the answer at this [link](https://stackoverflow.com/questions/39560288/unable-to-run-xamarin-android-project) did. – Gaurav Gahlot Feb 05 '17 at 08:38
4

I had a similar problem as explained below. Here a solution that worked for me:

1) delete the one package appearing in the screen shot below. Nota bene: At this stage VS 2015 greyed out the Android SDK manager buttons, even after a restart.

2) download installer_r24.4.1-windows.exe for windows https://developer.android.com/studio/index.html

3) launch the Android SDK Manager outside of VS and install the proposed 19 packages. This time I could go through the installation.

4) Launch VS 2015 and create Xamarin Android project. Launching Main.axml would launch the designer properly on an android project.

The bug I had

I had the same problem here on a fresh install of Win10 + Full visual studio community 2015 update 3 + .Net Core + Azure SDK and Xamarin. Creating a new project Xamarin Native (iOs + Androird) shows up the same message as mentioned by MikeJ. In addition, running in debug F5 makes the designer have a new popup

enter image description here

Problem seems to appear also here https://bugzilla.xamarin.com/show_bug.cgi?id=44374 and here https://forums.xamarin.com/discussion/77669/how-do-i-fix-this-error-the-installed-android-sdk-is-too-old-version-25-1-3-or-newer-is-required .

Opening the Android Manager does not show up version 25 as an option, instead it shows this

enter image description here

However, we cannot install (greyed out button even by accepting license)

enter image description here

Updating Xamarin did not work neither How to update Xamarin for Android within Visual Studio Community 2015

Some guidance would be great to understand what happened.

Community
  • 1
  • 1
Octopus
  • 661
  • 4
  • 21
2

I had the same problem (when bringing up a new PC with Xamarin) and after a few days I solved the problem.

I moved sdk directory from "C:\Program Files (x86)\Android\android-sdk" to "C:\android-sdk". Then I opened the sdk manager and made updates. It's all.

I think the problem is with the path, which has space :)

Marcin
  • 21
  • 1
1

I was able to to fix the issue by opening the Android SDK Manager and updating all the tools to the latest version.

bytedreamer
  • 142
  • 8
1

If you are already using Android Studio in your computer then this might solve your problem. Check whether SDK is already available at some other location. That worked for me. To check SDK path- Open Android Studio-> Click on SDK Manager Icon. Check Android SDK Location. Copy that path.

In Visual Studio-- Open Tools->Options->Xamarin->Android Settings menu and replace the new SDK path. It will automatically ask to download the updates. Install all packages and you are done!

1

before you go through all that trouble (and I went through many convoluted steps myself for several hours) please try run your VisualStudio as administrator and see what happens!

It solved the above issue (and then some) for me. I used fresh WIN 10 and VS2015 Community install and I must have set some of my permissions to tight.

Also I learned that updating my NuGet package: Xamarin.Forms (v.2.3.3.168) solved errors related to:

System.MissingMethodException: Method Android.Support.V4.Widget.DrawerLayout.AddDrawerListener not found.

But that is another issue all together.

Milan
  • 3,209
  • 1
  • 35
  • 46
1

Adding these two references to Droid.csproj and packages.config fixed the problem for me:

<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />

<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
F. Badili
  • 261
  • 3
  • 3
1

Another issue to be aware of is that you need to have Java Development Kit 8 referenced in Xamarin, instead of JDK 7. You can set this is Tools > Options > Xamarin > Android.

Sam Weaver
  • 1,027
  • 16
  • 30