Breaking Changes in Android SDK 26

July 21st 2017 Android Cordova Ionic 2/3

I have finally updated Android SDK to the latest version, because I wanted Android Studio to stop informing me about available updates on every startup. Unfortunately several breaking changes have been introduced since the version I was using before, which altogether broke my regular flow of work.

No More AVD Manager and SDK Manager

I first noticed that I couldn't start the standalone AVD Manager and SDK Manager graphical user interfaces any more. A window only appeared for a moment and immediately closed. Running the android command revealed the reason:

The "android" command is deprecated. For manual SDK, AVD, and project management, please use Android Studio.

Obviously the standalone executables have been deprecated as well. So, Android Studio it is. AVD Manager worked fine, however SDK Manager displayed the following warning and had all the functionalities disabled:

Android SDK location should not contain whitespace, as this can cause problems with the NDK tools.

I had Android SDK installed in C:\Program Files (x86)\Android\android_sdk. There didn't seem to be any other way to resolve the issue than to move the SDK to another path with no white space. I chose C:\android_sdk. To get everything working again, some extra steps were required:

  • Change the Android SDK Location setting in SDK Manager inside Android Studio to point to the new location: C:\android_sdk.
  • Add write permissions to the C:\android_sdk folder to regular users so that I don't have to start Android Studio with admin privileges in order to modify the SDK components installed.
  • Change the ANDROID_HOME environment variable to point to the new location.
  • Change all the subfolders of old SDK location that were listed in the PATH environment variable to the new location.
  • Delete all virtual devices in AVD Manager and recreate them because the old ones were still looking for system images in the old path (c:\Program Files (x86)\Android\android-sdk\system-images\) and therefore couldn't be started any more.

Now, I could finally manage my Android SDK configuration and start the Android emulator again.

Cordova Incompatibilities

When I tried to rebuild my Ionic application, I stumbled across the next problem. The build failed with the following error message:

Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.

As it turned out, the new SDK also broke my version of Cordova Android platform. Simply updating the platform wasn't enough, because the default version of Android platform is still 6.1.2, which doesn't work with the latest version of SDK. Explicitly selecting a newer version in the update command helped:

cordova platform update android@6.2.3 --save

With this change the Ionic application built successfully again and also ran on the Android emulator. My work process has been restored.

Lauching the Emulator Without Android Studio

As an unfortunate side effect of removing the standalone AVD Manager executable, it is now required to start Android Studio and even load an Android project in it just to run the Android emulator. This is a bit an overkill, however there are alternatives.

If you have only one virtual device in AVD Manager, then Ionic will start it automatically when you try to run the Android application:

ionic run android

If you want more control over which virtual device to run in the emulator, you can use the command line launcher:

emulator -avd Nexus_7_x64

The emulator.exe executable is placed in the tools subfolder of your Android SDK directory, but it should be in your path.

Nexus_7_x64 is the Name of the virtual device, which will be listed in the View Details window for the device in AVD Manager.

Rolling Back to Previous version of Android SDK

If for some reason you don't want to or can't apply all of the above changes immediately (e.g. update Android platform in your project), then your only option is to rollback the Android SDK tools to a previous version.

Since the links to old Android SDK releases don't seem to be publically listed, you will need to figure out the URL yourself. Based on the release notes the last working version should be 25.2.5, which can be downloaded here.

To rollback your Android SDK installation, replace the tools subfolder in your Android SDK directory with the one from the downloaded archive. This should fix all of the issues caused by the latest SDK, without any other changes to your setup or project.

Get notified when a new blog post is published (usually every Friday):

If you're looking for online one-on-one mentorship on a related topic, you can find me on Codementor.
If you need a team of experienced software engineers to help you with a project, contact us at Razum.
Copyright
Creative Commons License