Error could not determine sdk root

C:Androidsdkbin>sdkmanager Error: Could not determine SDK root. Error: Either specify it explicitly with --sdk_root= or move this package into its expected location: cmdline-toolslatest it...

Downloading the Android SDK 29+ (command line tools for Android) from https://developer.android.com/studio#downloads.

For «commandlinetools-linux-7302050_latest.zip» the process was different from earlier approaches. Earlier after unpacking, the top folder was called tools, but now the top folder is called cmdline-tools.

The problem seems to be that the sdkmanager expects to reside in an environment called. /YOURPATH/cmdline-tools/SOMETHING/bin but unpacks to /YOURPATH/cmdline-tools/bin for Linux anyway.

if you get

Error: Could not determine SDK root.

Error: Either specify it explicitly with —sdk_root= or move this
package into its expected location: <sdk>/cmdline-tools/latest/

Unpack and make sure you have this path to the sdkmanager.
/YOURPATH/cmdline-tools/latest/bin/sdkmanager

How To

To get this to work, first create the path to your intended Android SDK /opt/android-sdk/cmdline-tools/ then unpack the SDK zip file to that location, and you will have

/opt/android-sdk/cmdline-tools/cmdline-tools/bin/sdkmanager

Now rename the second «cmdline-tools» to «latest»

/opt/android-sdk/cmdline-tools/latest/bin/sdkmanager

And now it should work.

Question

Asked by alakmar S on December 12, 2020 (source).

C:Androidsdkbin>sdkmanager
Error: Could not determine SDK root.
Error: Either specify it explicitly with —sdk_root= or move this package into its expected location: cmdline-toolslatest

it shows like this, even after specifying the root in env variables.
ANDROID_SDK_ROOT C:Androidsdk

I am using windows 10 64 bit machine, I want to run flutter without android studio so followed instruction on this page https://medium.com/@quicky316/install-flutter-sdk-on-windows-without-android-studio-102fdf567ce4

Answer

Question answered by alakmar S (source).

Since new updates, there are some changes that are not mentioned in the documentation.
After unzipping the command line tools package,
the top-most directory you’ll get is cmdline-tools.
Rename the unpacked directory from cmdline-tools to tools, and place it under $C:/Android/cmdline-tools

now it will look like
$C:/Android/cmdline-tools/tools

and it will work perfectly.

  • Source: Stackoverflow.com

Issue

C:Androidsdkbin>sdkmanager
Error: Could not determine SDK root.
Error: Either specify it explicitly with –sdk_root= or move this package into its expected location: cmdline-toolslatest

it shows like this, even after specifying the root in env variables.
ANDROID_SDK_ROOT C:Androidsdk

I am using windows 10 64 bit machine, I want to run flutter without android studio so followed instruction on this page https://medium.com/@quicky316/install-flutter-sdk-on-windows-without-android-studio-102fdf567ce4

Solution

Since new updates, there are some changes that are not mentioned in the documentation.
After unzipping the command line tools package,
the top-most directory you’ll get is cmdline-tools.
Rename the unpacked directory from cmdline-tools to tools, and place it under $C:/Android/cmdline-tools

now it will look like
$C:/Android/cmdline-tools/tools

and it will work perfectly.

Answered By – alakmar Shafin

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

In this tutorial, we will discuss all the steps required to install Android Platform Tools and SDK Manager on Windows 10. This tutorial provides the steps for Windows 10, though the steps should be the same on other versions of Windows.

This post is useful for the developers using Android Platform Tools and SDK manager without installing Android Studio for the use cases including hybrid app development using Ionic. It also assumes that a valid JAVA_HOME environment variable exists pointing to the installation directory of Java.

You can follow How To Install Java 8 On Windows 10, How To Install Java 11 On Windows, How To Install Java 15 On Windows, or How To Install OpenJDK 15 On Windows to install Java on Windows. In case you are interested in developing Android applications using Android Studio, you can also follow How To Install Android Studio On Windows.

Step 1 — Download SDK Tools

Open the download tab of Android Studio and scroll down to the Command line tools only section. This section shows various options to download the SDK tools as shown in Fig 1.

Install Android Platform Tools and SDK Manager on Windows 10 - Download Options

Fig 1

Click the first link having the download option for Windows as highlighted in Fig 1. It will ask to accept to terms and conditions as shown in Fig 2.

Install Android Platform Tools and SDK Manager on Windows 10 - License Agreement

Fig 2

Go through the details, agree on the terms and conditions and click the Download Button to start the download.

Step 2 — Install Command Line Tools

In this step, we will install the Android Command Line Tools on Windows 10. Create the directory android-sdk at your preferred location and extract the content of the downloaded SDK Tools zip to this directory. Make sure that the extracted content is available within the android-sdk directory created by us as shown in Fig 3.

Install Android Platform Tools and SDK Manager on Windows 10 - Command Line Tools

Fig 3

Step 3 — Install Platform Tools

In this step, we will install the Android Platform Tools on Windows 10. Follow the same steps similar to Android SDK Tools to install Android Platform Tools using the download link as shown in Fig 4, Fig 5, and Fig 6.

Install Android Platform Tools and SDK Manager on Windows 10 - Platform Tools - Download Options

Fig 4

Install Android Platform Tools and SDK Manager on Windows 10 - Platform Tools - License Agreement

Fig 5

Install Android Platform Tools and SDK Manager on Windows 10 - Platform Tools

Fig 6

Step 4 — Configure Environment Variable

Right-click the My Computer or This PC on the desktop and click the Properties Option. Now click the Advanced system settings. It will show the System Properties dialog having Advanced Tab options as shown in Fig 7.

Install Android Platform Tools and SDK Manager on Windows 10 - System Properties

Fig 7

Click the Environment Variables Button and click the New Button in the first section. Set the Variable Name field to ANDROID_HOME and Variable Value to the android-sdk directory created by us in the previous step.

Similarly, also configure the environment variable ANDROID_SDK_ROOT to the android-sdk directory.

Also, make sure that the JAVA_HOME environment variable is set to the JDK installation directory. It must not end with the bin as we do with the system path variable.

Install Android Platform Tools and SDK Manager on Windows 10 - Environment Variables

Fig 8

Step 5 — Configure Commands

In previous steps, we have downloaded and extracted the Command Line Tools and Platform Tools to the android-sdk directory. Both the tools provide several command-line utilities which we need to run by going to the appropriate directory having the executable files.

We can make these commands available at the system level without going to these directories by adding the path to tools, toolsbin, and platform-tools to the system path as shown in Fig 9. Make sure that these executables do not break other commands having the same name before adding these paths to the PATH environment variable.

Install Android Platform Tools and SDK Manager on Windows 10 - System Path

Fig 9

Now open the Command Prompt and check the ADB and SDK Manager versions as shown in Fig 10. You might be required to restart the system to apply the environment variables set by us.

# Check adb version
adb --version

# It must show the installed adb version
Android Debug Bridge version 1.0.41
Version 31.0.0-7110759
Installed as E:toolsjavaandroid-sdkplatform-toolsadb.exe

# Check sdkmanager version
sdkmanager --version

# It will show the error as shown below
Error: Could not determine SDK root.
Error: Either specify it explicitly with --sdk_root= or move this package into its expected location: <sdk>cmdline-toolslatest

We can see that the ADB command works well and shows the version details, but the sdkmanager shows an error — «error: could not determine sdk root. error: either specify it explicitly with —sdk_root= or move this package into its expected location: <sdk>cmdline-toolslatest» since it expects the Command Line Tools in a version-specific directory. Now open the source.properties file from the cmdline-tools directory to check the version. It will show the version details as shown below.

Pkg.Revision=3.0
Pkg.Path=cmdline-tools;3.0
Pkg.Desc=Android SDK Command-line Tools

Now move all the files to the directory cmdline-tools/3.0 as shown in Fig 10.

Install Android Platform Tools and SDK Manager on Windows 10 - Command Line Tools

Fig 10

Also, update the system path as shown in Fig 11.

Install Android Platform Tools and SDK Manager on Windows 10 - System Path

Fig 11

Now close and open the Command Prompt. Also, check the ADB and SDK Manager versions as shown in Fig 12.

Install Android Platform Tools and SDK Manager on Windows 10 - Version Checks

Fig 12

Step 6 — Using the SDK Manager

List — We can list the installed and available packages and images using the list command as shown below.

// List all the installed and available platforms, system images and other resources 
sdkmanager --list

// Output should look like
Installed packages:=====================] 100% Computing updates...
Path | Version | Description | Location
------- | ------- | ------- | -------
platform-tools | 31.0.0 | Android SDK Platform-Tools 31 | platform-tools

Available Packages:
Path | Version | Description
------- | ------- | -------
add-ons;addon-google_apis-google-15 | 3 | Google APIs
...
...

// We can see that it shows the tools and platform-tools installed by us

Install Platform — Use the below-mentioned command to install the Android 10 (API level 30) using the SDK manager.

# Go to the SDK Tools bin directory to access sdkmanager
# Start download the most recent package
sdkmanager "platforms;android-30"

It will ask to accept the terms and conditions as shown in Fig 13. Enter y and hit Enter Key to accept the terms and conditions. This command creates the directory platforms within android-sdk and installs the package android-30 having all the required files to run the emulator for Android 10.

Install Android Platform Tools and SDK Manager on Windows 10 - SDK License Agreement

Fig 13

If we again check the installed packages, the list command shows the installed options as shown below.

sdkmanager --list
Installed packages:=====================] 100% Computing updates...
Path | Version | Description | Location
------- | ------- | ------- | -------
platform-tools | 31.0.0 | Android SDK Platform-Tools 31 | platform-tools
platforms;android-30 | 3 | Android SDK Platform 30 | platformsandroid-30

Available Packages:
Path | Version | Description
------- | ------- | -------
add-ons;addon-google_apis-google-15 | 3 | Google APIs
add-ons;addon-google_apis-google-16 | 4 | Google APIs
...
...

Update SDK Manager — Update the SDK manager using the below-mentioned command.

sdkmanager --update

Add System Image — We can add system images from available images shown by the list command using the SDK manager as shown below. We are adding the most recent default 64-bit system image.

// Install default system image for platform android-30
sdkmanager "system-images;android-30;google_apis;x86_64"

Accept the License Agreement to complete the download.

There are several projects which need Google Play Services. We need system images specific to Google Play Services as shown below.

// Install Google Play Services system image
sdkmanager "system-images;android-30;google_apis_playstore;x86_64"

Accept the License Agreement to complete the download.

Install Emulator — We need to install the emulator before creating the AVD using SDK Manager.

// Install Emulator
sdkmanager --channel=3 emulator

Accept the License Agreement to complete the download.

Install Build Tools — Install the most recent build tool listed by the list command.

// Install Build Tools
sdkmanager "<build tools version>"

// Example
sdkmanager "build-tools;30.0.3"

Step 7 — Using the Emulator and AVD Manager

Create Android Emulator — Create the emulator using the system image downloaded in the previous step as shown below. Replace <emulator name> with the actual name preferred by you.

// Create the emulator using default system image
avdmanager create avd -n <emulator name> -k "system-images;android-30;google_apis;x86_64" -g "google_apis"

// Example:
avdmanager create avd -n emulator30 -k "system-images;android-30;google_apis;x86_64" -g "google_apis"

// Create emulator using Google Play Services system image
avdmanager create avd -n <emulator name> -k "system-images;android-30;google_apis_playstore;x86_64"

// Example:
avdmanager create avd -n emulator30ps -k "system-images;android-30;google_apis_playstore;x86_64"

The above commands ask a bunch of questions to configure the AVD if we choose the custom hardware profile option. We have excluded the details of these options from this tutorial since these configuration details depend on the actual needs. After completing all the configurations, it creates the AVD using the name provided by us while configuring it.

Similarly, we can also install the AVD of older versions as shown below.

// Create the emulator using default system image
avdmanager create avd -n <emulator name> -k "system-images;android-29;default;x86_64" -g "default"

// Example:
avdmanager create avd -n emulator29 -k "system-images;android-29;default;x86_64" -g "default"

// Create emulator using Google Play Services system image
avdmanager create avd -n <emulator name> -k "system-images;android-29;google_apis_playstore;x86_64"

// Example:
avdmanager create avd -n emulator29ps -k "system-images;android-29;google_apis_playstore;x86_64"

List Android Emulators — Now go to the tools directory on the command line and check the installed platform as shown below.

Notes: Add Emulator to the system path as shown in Fig 14.

Install Android Platform Tools and SDK Manager on Windows 10 - Emulator Path

Fig 14

Close and re-open the Command Prompt to check the AVDs created by us in the previous steps.

// List the available emulators
emulator -list-avds

// Output
default28
emulator30
emulator30ps

It will list all the AVDs installed by us.

Run Emulator — We can run the emulator created by us as shown below.

// Run Emulator
emulator -avd <emulator name>

// Example

emulator -avd emulator30

The emulator will take some time to completely launch the AVD. The final results should look similar to Fig 15.

Install Android Platform Tools and SDK Manager on Windows 10 - AVD

Fig 15

Delete Emulator — We can also delete an existing emulator as shown below.

// Delete Emulator
avdmanager delete avd -n <emulator name>

Summary

This tutorial provided all the steps required to install Android Platform Tools and Android SDK Manager on Windows 10. It also provided the steps required to create and launch the AVDs using the Emulator.

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account


Closed

J4NV5 opened this issue

Dec 10, 2021

· 6 comments


· Fixed by #23


Closed

Flutter: Android license status unknown

#18

J4NV5 opened this issue

Dec 10, 2021

· 6 comments


· Fixed by #23

Comments

@J4NV5

It appears the use of this library with flutter does successfully include Android SDK, but flutter doctor says ✗ Android license status unknown., and of course running flutter doctor --android-licenses produces an error:

Error: Could not determine SDK root.
Error: Either specify it explicitly with --sdk_root= or move this package into its expected location: <sdk>/cmdline-tools/latest/

How are the licenses handled? I knew with previous iterations of using the android SDK with flutter, the license was a read-only nix path, and could not easily be accepted deterministically. How do you accomplish this with this library?

Thank you

@tadfisher

How are you using this with your project?

A working Android SDK needs to use the sdk function (or pkgs.androidSdk if using the overlay). That creates what the Android SDK tools expect to see, including a $out/licenses/ directory which contains the accepted hashes of license files.

If you are using the function, then go ahead and pass --sdk_root=${sdk}/share/android-sdk as flutter doctor asks and let me know if that works.

@J4NV5



Copy link


Contributor

Author

thanks for the quick reply!
this is how I arrived at the current state:

nix flake init -t github:tadfisher/android-nixpkgs

Then from devshell.nix I changed mkDevShell -> to pkgs.devshell.mkShell and the env to a list of submodules

env = {
ANDROID_HOME = «${android-sdk}/share/android-sdk«;
ANDROID_SDK_ROOT = «${android-sdk}/share/android-sdk«;
JAVA_HOME = jdk11.home;
};

.

Apparently those needed to be updated.

Then I just added flutter to the mkShell packages, then ran:

nix develop
flutter doctor

@J4NV5



Copy link


Contributor

Author

(I did a PR for the above changes)
#21

@J4NV5



Copy link


Contributor

Author

$ sdkmanager --licenses

Warning: This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
4 of 6 SDK package licenses not accepted. 100% Computing updates...             
Review licenses that have not been accepted (y/N)? 

So maybe missing 2 of the licenses?

EDIT:

the --sdk_root attribute is part of sdkmanager, flutter doctor --android-licenses invokes it.

@tadfisher

So:

  • There are 6 total android SDK licenses available for accepting.
  • android-nixpkgs.sdk copies the license hashes only for the packages you install.
  • The default setup from the template only requires android-sdk-license and android-sdk-preview-license to be approved
  • sdkmanager --licenses displays all possible licenses you can accept, not only the ones that need accepting for the SDK packages you have installed.
  • Thus sdkmanager --licenses is not the ideal way to check if the SDK is working or not.
  • However, to support flutter doctor I can add all possible license hashes to the sdk output.

Let me see if this is feasible without bloating the closure size of a basic SDK.

@tadfisher

sdkmanager --licenses should pass now.

2 participants

@tadfisher

@J4NV5

C: Android sdk bin> sdkmanager Ошибка: не удалось определить корень SDK. Ошибка: либо укажите его явно с помощью —sdk_root =, либо переместите этот пакет в ожидаемое место: cmdline-tools latest

Это выглядит так, даже после указания корня в переменных env. ANDROID_SDK_ROOT C: Android sdk

Я использую 64-битную машину с Windows 10, я хочу запустить Flutter без Android Studio, поэтому следуйте инструкциям на этой странице https://medium.com/@quicky316/install-flutter-sdk-on-windows-without-android-studio-102fdf567ce4

3 ответа

Лучший ответ

С момента выхода новых обновлений есть некоторые изменения, не упомянутые в документации. После распаковки пакета инструментов командной строки, самый верхний каталог, который вы получите, — это cmdline-tools. Переименуйте распакованный каталог из cmdline-tools в tools и поместите его в $ C: / Android / cmdline-tools.

Теперь это будет выглядеть как $ C: / Android / cmdline-tools / tools

И это будет работать отлично.


37

alakmar Shafin
12 Дек 2020 в 08:21

Вы можете создать папку latest внутри вашего cmdline-tools и переместить все ее содержимое в эту папку. Итак, ваш полный путь будет C:Androidcmdline-toolslatestbin. При использовании этой конфигурации нет необходимости определять переменную среды ANDROID_SDK_ROOT или параметр --sdk_root=. Предполагается, что ваша папка SDK — C:Android, и помещает в нее все ваши файлы (образы системы, лицензии и т. Д.).


1

Marcelo Barros
14 Фев 2021 в 18:43

Если вы не хотите перемещать его в другое место, вы можете использовать --sdk_root, чтобы указать папку, в которую вы хотите установить и загрузить Android SDK.

Например, если вы хотите использовать: X:DevAndroidSDK и вы загрузили и разархивировали пакет инструментов командной строки в этой папке, у вас будет следующий путь: X:DevAndroidSDKcmdline-toolsbin для sdkmanager.bat.

Итак, ваша команда будет:

X:DevAndroidSDKcmdline-toolsbin>.sdkmanager.bat --sdk_root=X:DevAndroidSDK

PS: не используйте пробелы в пути к AndroidSDK, иначе это не сработает


1

Juan Antonio Tubío
13 Фев 2021 в 17:26

Понравилась статья? Поделить с друзьями:
  • Error could not determine executable to run
  • Error could not create the java virtual machine сервер майнкрафт
  • Error could not create the java virtual machine как решить
  • Error could not create the java virtual machine ubuntu
  • Error could not create the java virtual machine minecraft что делать windows 10