Can’t open Xamarin Android .axml file: The install

2020-04-01 05:35发布

问题:

I'm using Visual Studio and am unable to open layout files in the Xamarin Android Designer. I get this error when I try:

Something went wrong
The installed Android SDK is too old. Version 25.1.3 or newer is required. Please update to the latest version.

I’ve already updated Xamarin, and am still stuck. How can this be fixed?

回答1:

I recently ran into The installed Android SDK is too old. Version 25.1.3 or newer is required. Please update to the latest version. myself and found that I had to update the Android SDK in two stages to get things working.

As other users have mentioned, only updates for version 24.x.x were showing, while version 25.x.x was nowhere to be found. I installed the available updates for Tools, Platform-Tools, and Build-Tools, then exited and reopened the Android SDK Manager. This worked; version 25.x.x was now available for installation.

tl, dr;

  1. Install 64-bit JDK 1.8
  2. Update Android SDK Tools, Platform-tools, and Build-tools. Close SDK Manager and repeat if the version required in the warning isn’t shown. You may need to exit Visual Studio if you get "Warning! A folder failed to be moved"
  3. Make sure the Android settings in Visual Studio are pointing to the right locations: Tools > Options > Xamarin > Android Settings
  4. Keep the Xamarin installation up to date! Tools > Options > Xamarin > Other > “Check Now”

Unsure if that was a one-off, I decided to do a fresh Xamarin installation with Visual Studio 2015 on Windows 10. Here is how I reproduced the issue and got back to working with layout files. This is long and these steps can probably be streamlined, but I wanted to give a clear picture of what I did.

Here is my step-by-step process:

  1. Download Xamarin for Windows
  2. Update to Xamarin latest Stable: Tools > Options > Xamarin > Other > “Check Now”
  3. Open Android SDK Manager, update Build-tools from v23.0.3 to v24.0.3
  4. Uninstall Build-tools v23.0.3, close SDK Manager
  5. Close & reopen layout file, get "too old" message
  6. Open SDK Manager, update to Build-tools v25, uninstall Build-tools v24.0.3
  7. Close SDK manager & layout file
  8. Reopen open layout file, get same message
  9. Open SDK Manager, update to Platform-tools v25
  10. Close SDK Manager & layout file
  11. Reopen layout file, still too old
  12. Open SDK Manager, update SDK Tools from v25.1.2 to v25.2.2

Here, I got the same warning mentioned in another SO post

Carrying on:

  1. Exit Visual Studio; dismiss warning and process continues fine
  2. The warning came back; dismissing again allows process to complete
  3. Close SDK Manager, open Visual Studio, load Android project, open and layout file. Success! I can view layout files again.

There are a few additional things I’d like to mention to minimize potential snags/confusion:

  • Android Studio is not required. In addition to the prompt in the “SDK is too old” message, the Android SDK Manager can be opened via Tools > Android > Android SDK Manager or the SDK Manager toolbar icon.

  • My personal practice is to have only one version of the Build-tools installed to help minimize potential conflict or upstream issues, such as a couple that came up while using “version 24”.

  • Xamarin.Android 7.0 requires JDK 1.8. If you have not already done so, consider installing 64-bit JDK 1.8. This is the simplest option since it is backwards compatible with all previous API levels, it supports the new Android designer features, and the 64-bit version is required to use custom controls in the Android designer.
  • After updating, go to Tools > Options > Xamarin > Android Settings to verify that the correct locations are pointed to for the JDK, Android SDK, and Android NDK.

I’d also like to note that Android SDK updates are not specific to Xamarin. If we’re developing for Android, we need these tools for things like emulators, debugging, signing APKs, and accessing the newest platform features, whether using Xamarin or not.

For the curious, more details can be found here:
- Android Studio Command Line Tools doc
- What are the Android SDK build-tools, platform-tools and tools? And which version should be used?



回答2:

I've solved this problem. First, download Android SDK tool 25.1.3 from Google here and extract it. Then, remove the existing 'tools' folder under SDK like D:\\android-sdk\tools.

After removing it, put the 'tools' folder you recently extracted under the android-sdk path. Finally, restart your vs. This is working sucessfully for me. I'm running on Windows 7 32-bit.