Provide the path to the android sdk что это

How to install Android SDK and setup AVD Emulator without Android Studio

If you are trying to develop to Android, you probably will end up installing the Android Studio to get the Android SDK and the AVD Emulator working properly.

But if you are using another code editor, like Sublime Text or VSCode, installing the Android Studio will just mess up with your setup and consume your precious RAM for no good reason.

I had a hard time figuring out how to properly do this setup due the lack of documentation about it, so i hope this article helps you. 🙂

Recommended previous knowledge:

  • SDK (Standard Development Kit); Read about on Wikipedia;
  • AVD (Android Virtual Device); Read about on docs;
  • CLI (Command Line Interface); Read about on Wikipedia;
  • Android API levels; Read about on Vanderbilt University;
  • How to open, navigate and execute files in your OS terminal;
  • Know what are environmental variables;

Understanding the Android SDK

Basically, the Android SDK is a bunch of packages necessary to develop for Android.

These packages stays in subfolders of a folder called “sdk” (or “android-sdk” sometimes). You do not need to know how these packages really work, just what they do.

The picture below is my Android SDK folder, these are the basic packages you will need in order to get everything working properly.

Here is a brief explanation of each package:

  • tools: This package is mainly used to manage the other packages and to create AVD’s;
  • emulator: As the name suggest, this is the Android emulator;
  • platform-tools: Some tools to communicate with Android devices when you plug then in your computer;
  • patcher: This package is automatically downloaded by the SDK. I didn’t find what exactly this is for, so just leave it as it is;

The folders bellow contain sub-folders with the packages for each Android API level.

  • platforms: The platform packages are required to compile your app for the specified API level.
  • system-images: These are the android images used in the emulator.
  • build-tools: These are necessary to build your Android apps

Installing the Android SDK

In order to install the SDK we will use the Command Line Tools. These are some quite simple CLI’s used to manage the Android SDK. You can read the documentation here for more details.

Step 1 — Download the tools package

First, you need to download the tools package. And with this package you can download the others.

  1. First, go to the Android Studio download page: https://developer.android.com/studio;
  2. Then click in “ Download Options”;
  3. There you will find a table named “ Command line tools only”;
  4. This table contain some zip files. Download the appropriate file for your system ( Windows, Mac or Linux);
  5. Extract this zip and you will get a folder called tools: This is the tools package i explained earlier;
Читайте также:  Страна чудес для андроид

Create a folder anywhere you prefer to place your SDK. I recommend you to stick with one of these commonly used places:

  • Globally: C:\Android\sdk or C:\android-sdk (this is not default, but i usually set my SDK here on Windows)
  • One user only: C:\Users\ \AppData\Local\Android\sdk
  • Globally: /Library/Android/sdk
  • One user only: /Users/ /Library/Android/sdk

And move the tools folder to this new sdk folder. Make sure you have admin access to this folder and any sub-folders inside it, or the tools package will fail to download new packages.

Note: You can also download a pre-build package for your SO (like the one available on Ubuntu repository). But i do not recommend you do to so, because they probably will not be updated and will be harder to manage, since it was automatically installed.

Step 2— You need Java 8!

The Android SDK packages require Java 8. If you do not have it, you need to download. If you are using a newer version, you have to downgrade to Java 8 or you will eventually get some errors, because it is not compatible.

If you do not have the Java 8 SDK, here is how you can install it:

On Ubuntu run these commands:

  • # sudo apt-get update
  • # sudo apt-get install openjdk-8-jdk

Sorry for MacOS users, i don’t know how to install it on this OS.

Step 3 — Download the essential packages

Now, download the platform-tools and the emulator packages, because they contain some CLI binary files you will need later. I decided to download these packages first in order to set all the necessary environment variables at once and make the rest of the process easier.

Open a terminal window (you need to use a terminal, not the file explorer), go to your sdk folder and navigate to the /tools/bin directory.

This folder contain the SDKManager binary: this is a CLI used to list the available packages in the Google’s repository and download, update or remove them from your SDK folder.

The bellow command will list all packages installed (the first items on the list) and all packages available to download:

To download the packages, simply copy the package names and pass it as a parameter to the SDKManager CLI using the terminal:

# ./sdkmanager platform-tools emulator

If you open your sdk folder you should see these packages folders there.

Step 4 — Set your environmental variables

You need to set the below environmental variables containing the path to our SDK, so any running program can find it in your pc:

ANDROID_SDK_ROOT = Path to your SDK folder

ANDROID_HOME = The same as ANDROID_SDK_ROOT. This variable is now deprecated, but i recommend setting it because some programs still using it to locate your sdk.

And add these folders to the PATH variable, making their binary files accessible from everywhere:

To add the environment variables on WIndows, just follow these steps:

  1. Open the “Control Panel”;
  2. Go to “ System and Security” option in the side menu;
  3. In the window “ System Properties” open the tab “ Advanced”;
  4. Click in the button “ Environment Variables” in the bottom of the page;
  5. In the “ Environment Variables” window you will see two tables: “User Variables” and ” System Variables”.
  6. If you created your sdk folder for one user only, set the variables in the “ User Variables” table;
  7. But, if you create your sdk folder globally, set the variables in the “ System Variables” table instead;

On Linux, you can set your environment variables in many places. So i choose the ones I found the most appropriate:

    If you created your sdk folder for one user only, set your environment variables in the file

/.bashrc;

  • If you created your sdk folder globally, set your environment variables in the /etc/environment file. But, be very careful! if you do something wrong with the path variable in this file you will broke your system (yes, i did this). This file is not a script, so you can’t use variables like $HOME, you need to write the full path to the folders. Variables declared in this file just will take effect after you logout .
  • Читайте также:  Как полностью почистить память андроид

    Here is how i set these variables in my Ubuntu, using the file /etc/environment:

    And sorry again, no MacOS instructions for this task.

    You can find more about these environmental variables in the oficial docs here.

    Now your SDK is ready! If you do not need to run the emulator there’s no need to follow the next steps.

    Step 5 — Download the platform specific packages you want

    You need more three packages: The platform, the system-image and the build-tools. You can download these packages for any Android version you prefer. In this article, i will download the packages for the API Level 28.

    Use the “ sdkmanager — list” command to find these packages and download them using the command “ sdkmanager

    Here’s an example:

    Step 5 — Create a AVD device

    Creating a AVD device is a simple task: run the AVDManager command (this is a binary file located in the tools/bin folder of your sdk) with the create avd option, a name for the new AVD and the image you want to use.

    Here is a example:

    # avdmanager create avd — name android28 — package “system-images;android-28;default;x86”

    You will be asked if you want to alter some configurations. You can also modify these configurations later in the file config.ini, located in the avd folder (this folder usually is created in your user folder, under the android directory). The currently active configurations can be find in the file hardware-qemu.ini (this file just will be created after the emulator runs for the first time).

    Step 6 — Run the Android Emulator

    Now you just need to run the emulator command (remember that we added this package to the environmental variables?):

    The emulator take some time to init for the first time. But if you done everything correctly you should see this screen:

    Источник

    Arch Linux

    You are not logged in.

    #1 2013-06-26 01:08:58

    [SOLVED] Android Studio Requiring Path to Android-SDK

    I’ve installed Android Studio, but whenever it loads I am prompted with the below message. Entering /opt/android-sdk doesn’t work. Any ideas?

    Mod Edit: Changed large in-line image to a link. Our policy

    Last edited by tony5429 (2013-07-04 13:41:40)

    #2 2013-06-26 02:46:03

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    I ran into that same issue; I don’t know why it doesn’t like the one installed there. However, it did work once I pointed it to one downloaded into my home directory (by Eclipse).

    #3 2013-06-26 03:02:24

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    sounds like a permissions problem to me.

    #4 2013-06-26 11:15:36

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    Interesting. This is what I’ve currently got.

    #5 2013-06-26 17:36:17

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    have you tried running it from the terminal to see what kind of output you get? If you check out the arch wiki for android, it makes a couple of recommendations for changing the owner of /opt/android-sdk to your user or a new group, of which your user is a member of. I’m not on my pc now, but I’m pretty sure my user is the owner of my android-sdk. I will check in a minute.

    EDIT: Yes, as I suspected, my user owns /opt/android-sdk. Some people might prefer the group approach, though.

    Last edited by cris9288 (2013-06-26 17:41:26)

    #6 2013-06-27 02:33:48

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    Thanks, cris9288. After chowning, Android Studio now fully loads and then prompts for the SDK directory, and then accepts it each time I provide /opt/android-sdk. However, upon clicking «New Project,» I am met with the error «Your Android SDK is out of date or is missing templates. Please ensure you are using SDK version 22 or later.» As seen in the output below, I am in fact using version 22 of the SDK, as well as the latest version of Android Studio. Any ideas?

    #7 2013-06-28 02:29:55

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    I just recorded a video of the error: www.youtube.com/watch?v=xy7Ano4Ibyk

    Anyone have any ideas what’s going on here?

    #8 2013-06-28 03:02:00

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    I think part of the android-sdk package is a file in /etc/profile.d that is used to update your $PATH. I use only the android-sdk-platform-tools, as I have no need for the rest, but that appends /opt/android-sdk/platform-tools to my $PATH.

    Читайте также:  Android iconia tab планшет

    Can you check to make sure you your PATH variable is set up this way? If it is not, source /etc/profile, which sould in turn source all files in /etc/profile.d and add this. or if you want you can first check to make sure that I am correct in my remembering the addition to /etc/profile.d. You can check this with «pacman -Ql android-sdk | grep profile.d»

    #9 2013-06-29 02:45:12

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    Thanks, WonderWoofy. It looks like you’re right, but I do already have android-sdk in my path.

    #10 2013-06-29 03:04:15

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    Okay. well unfortunately, I have never used this software and that was every idea I have on the topic.

    #11 2013-07-04 13:30:17

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    I completely uninstalled all Android packages, downloaded the latest ones, and reinstalled paying closer attention to the wiki page. Everything works now! I did have to chown the directory still. Previously I was missing the build-tools package, and the platform-specific zip file.

    #12 2013-07-04 16:38:16

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    Ah, you never got it set up then. That is something that I actually did when I installed the stuff. I did have the full android-sdk for a while thinking it might be of use. But I realized after a while that Android didn’t pique my interest in the same way as tinkering with Arch Linux does. So all needed were adb and fastboot in order to unlock the bootloader of my Nexus 7.

    I’m glad you got this working!

    #13 2014-10-20 20:15:48

    Re: [SOLVED] Android Studio Requiring Path to Android-SDK

    I hope this message will help for all of you who got the same errors on SDK window saying (failed to create directory blablabla. ).

    For Arch beginners and all’ye who are lazy- use yourt-gui (from AUR, really nice to quickly done this kind of job, its like installing AUR applications from normal official repositories. Quickly!)

    This is what I have done.
    1. android-studio, android sdk, java, adb, fastboot. make sure you uninstall all of them. I also deleted all dependencies (also using yaourt-gui).
    2. If you are using jdk8-openjdk — uninstall it, remove all dependencies, just get rid of it! then install «jdk» from AUR (its oracle’s jdk). If you install JDK from oracle you won’t get any warning messages. If you are already using oracle jdk — skip this step.
    3. not sure if necesarry to install all of them, I was using yourt-gui and I just pasted all those applications and installed them all, some of them was from AUR:

    android-sdk android-sdk-platform-tools android-sdk-build-tools android-platform android-tools android studio

    4. reboot pc
    5. open terminal, run this command AS ROOT (and change to your name):

    chown -R :wheel /opt/android-sdk/

    this command sets your normal user as an owner of /opt/android-sdk so you will be able to edit files as normal user at /opt/android-sdk/ directory without root permissions, that means you will be able to use android sdk as normal user.
    6. open Android-studio. at the settings put there android-sdk directory path. it shouldn’t say any errors about invalid sdk etc.
    7. open SDK and install what you need. All I did at the beginning was just clicked «install/update» without changing any selections
    8. In sdk manager, select and install: extras —> android support repository. (it might be installed so it won’t be necesarry, but I had error and found a solution here http://stackoverflow.com/questions/1962 … pportappco . nevermind)

    P.S. I won’t be suprised if I get here an angry admin’s post complaining about revived from stoneage thread or not clear information etc. I just wrote what I have done so far to get it successfully working. Maybe some users will find it useful if they stuck!

    Last edited by erkexzcx (2014-10-20 20:17:35)

    Allergic to admins&moderators. They scare me.

    Источник

    Оцените статью