Linux android ndk path

Install and configure the NDK and CMake

To compile and debug native code for your app, you need the following components:

  • The Android Native Development Kit (NDK): a set of tools that allows you to use C and C++ code with Android.
  • CMake: an external build tool that works alongside Gradle to build your native library. You do not need this component if you only plan to use ndk-build.
  • LLDB: the debugger Android Studio uses to debug native code. By default, LLDB will be installed alongside Android Studio.

This page describes how to install these components automatically, or by using Android Studio or the sdkmanager tool to download and install them manually.

Install NDK and CMake automatically

Android Gradle Plugin 4.2.0+ can automatically install the required NDK and CMake the first time you build your project if their licenses have been accepted in advance. If you’ve already read and agree to the license terms, then you can pre-accept the licenses in scripts with the following command:

 yes | $/cmdline-tools/latest/bin/sdkmanager --licenses 

Install the NDK and CMake

When you install the NDK, Android Studio selects the latest available NDK. For most projects, installing this default version of the NDK is sufficient. If your project needs one or more specific versions of the NDK, though, you can download and configure specific versions. Doing so helps you ensure reproducible builds across projects that each depend on a specific version of the NDK. Android Studio installs all versions of the NDK in the android-sdk /ndk/ directory.

To install CMake and the default NDK in Android Studio, do the following:

Image of SDK Manager

  1. With a project open, click Tools > SDK Manager.
  2. Click the SDK Tools tab.
  3. Select the NDK (Side by side) and CMake checkboxes. Figure 1. The SDK Tools window showing the NDK (Side by side) option Note: If you have an NDK installed in the ndk-bundle folder, it appears in the list with the label NDK. If you are using Android Gradle plugin 3.5.0 or later, you can select this checkbox or clear it. Clearing the checkbox uninstalls the NDK, freeing up disk space, and causes the checkbox to disappear from the list. If you uninstall the legacy NDK, remove the ndk.dir value, which is now deprecated, from your projects’ local.properties files.
  4. Click OK. A dialog box tells you how much space the NDK package consumes on disk.
  5. Click OK.
  6. When the installation is complete, click Finish.
  7. Your project automatically syncs the build file and performs a build. Resolve any errors that occur.

Configure a specific version of CMake

The SDK Manager includes the 3.6.0 forked version of CMake and version 3.10.2. Projects that don’t set a specific CMake version are built with CMake 3.10.2. To set the CMake version, add the following to your module’s build.gradle file:

Читайте также:  Перезагрузка службы ssh linux

Groovy

Kotlin

If you want to use a CMake version that is not included by the SDK Manager, follow these steps:

  1. Download and install CMake from the official CMake website.
  2. Specify the CMake version you want Gradle to use in your module’s build.gradle file.
  3. Either add the path to the CMake installation to your PATH environment variable or include it in your project’s local.properties file, as shown. If Gradle is unable to find the version of CMake you specified in your build.gradle file, you get a build error.
# If you set this property, Gradle no longer uses PATH to find CMake. cmake.dir = "path-to-cmake"

Install a specific version of the NDK

To install a specific version of the NDK, do the following:

Image of SDK Tools window

  1. With a project open, click Tools > SDK Manager.
  2. Click the SDK Tools tab.
  3. Select the Show Package Details checkbox.
  4. Select the NDK (Side by side) checkbox and the checkboxes below it that correspond to the NDK versions you want to install. Android Studio installs all versions of the NDK in the android-sdk /ndk/ directory. Note: Preview releases (for example, canary and beta) of the NDK do not show up in this list unless you change the update channel for Android Studio. You can install an Android Studio preview side-by-side with the stable version. Figure 2. The SDK Tools window showing the NDK (Side by side) options Note: If you have an NDK installed in the ndk-bundle folder, it appears in the list with the label NDK. If you are using Gradle version 3.5 or later, you can select this checkbox or clear it. Clearing it uninstalls the NDK installed, freeing up disk space, and cause the checkbox to disappear from the list. If you uninstall the legacy NDK, remove the ndk.dir value, which is now deprecated, from your projects’ local.properties files.
  5. Click OK. A dialog box tells you how much space the NDK package(s) consumes.
  6. Click OK.
  7. When the installation is complete, click Finish.
  8. Your project automatically syncs the build file and performs a build. Resolve any errors that occur.
  9. Configure each module with the version of the NDK you want it to use. When using Android Studio 3.6 or higher, if you do not specify the version, the Android Gradle plugin chooses a version that it is known to be compatible with.

Configure specific versions of the NDK in your project

You may need to configure the version of the NDK in your project if one of the following is true:

  • Your project is inherited and you need to use specific versions of the NDK and the Android Gradle plugin (AGP). For more information, see Configure the NDK for the Android Gradle plugin.
  • You have multiple versions of the NDK installed and you want to use a specific one. In this case, specify the version using the android.ndkVersion property in the module’s build.gradle file, as shown in the following code sample.

Groovy

android < ndkVersion "major.minor.build" // e.g., ndkVersion "21.3.6528147" >

Kotlin

android < ndkVersion no">major.minor.build" // e.g., ndkVersion "21.3.6528147" >

Default NDK version per AGP version

Before release, each AGP version is thoroughly tested with the latest stable NDK release at that time. For AGP version 3.6 and above, that NDK version will be used to build your projects if you do NOT specify an NDK version in the build.gradle file. The default NDK version is documented inside the AGP release notes. The current default NDK versions are listed in the following table:

Android Studio/Gradle Plugin Version Default NDK version
specified for the version of AGP
8.0 25.1.8937393
7.4 23.1.7779620
7.3 23.1.7779620
7.0 21.4.7075529
4.2 21.4.7075529
4.1 21.1.6352462
4.0 21.0.6113669
3.6 20.0.5594570
3.5 and older No default specified

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2023-07-05 UTC.

Источник

How to install android ndk in linux?

I have downloaded android NDK from here: http://developer.android.com/tools/sdk/ndk/index.html
for Linux 64-bit (x86) android-ndk-r10c-linux-x86_64.bin. How I do install it? The instructions don’t work. My OS is

57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux 

10 Answers 10

The Standard Way

Android’s NDK now ships as an self extracting executable. You likely need to set the executable bit:

$ chmod +x android-ndk-r10c-linux-x86_64.bin $ ./android-ndk-r10c-linux-x86_64.bin 

The above will cause the NDK to extract into the current working directory.

Manual Extraction

Since the .bin file is really just a 7-Zip self extracting archive, you can manually extract the contents if needed:

$ 7za x -o/path/to/extract/to/ android-ndk-r10c-linux-x86_64.bin 

7-Zip is available in Ubuntu for example via apt-get:

$ sudo apt-get install p7zip-full 

Update
As of at least r14b on the NDK download page, we’re back to standard ZIP archives.

You may want to post some more information other than «It doesn’t work». See stackoverflow.com/help/how-to-ask

./android-ndk-r10c-linux-x86_64.bin: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

@Vardan95: That is answered here: stackoverflow.com/questions/11471722/… Alternatively, you can use the manual instructions I added.

and where can this .bin file be found? All I see are .zip files, (and no README to be seen anywhere, shame on you Google)

If you already have AndroidStudio installed:

You can install NDK using the SDK Manager from within Android Studio

From an open project, select Tools > Android > SDK Manager from the menu bar. Click the SDK Tools tab. Check the boxes next to LLDB, CMake, and NDK. Apply

ubuntu does not install by default Android Studio and nowhere in the question is mentioned that it is installed. So the answer is incorrect unless: First install Android Studio is provided before «install NDK using the SDK Manager from within Android Studio«

Another way to download and install (unpack) it (size of zip is ~820MB, unzipped is ~2.9G):

wget https://dl.google.com/android/repository/android-ndk-r20-linux-x86_64.zip unzip android-ndk-r20-linux-x86_64.zip 

Go to the directory where you downloaded it. Then execute:

chmod +x android-ndk-r10c-linux-x86_64.bin ./android-ndk-r10c-linux-x86_64.bin 

It should unpack right there. The toolchain will be in android-ndk-r10c-linux-x86_64/toolchains. The root folder might have a slightly different name.

Unfortunately this is not correct, because android-ndk-r10c-linux-x86_64.bin is an ELF executable, not a shell script.

Install 7-Zip via apt-get like this

$ sudo apt-get install p7zip-full 

go to folder where your ndk bin is and then execute the command

I have androidBBQ which is archlinux based, installed using vmware. But I guess my instructions should be the same for any linux distribution. I used AndroidStudio’s built-in SDK manager, to try installing NDK. Download failed because there was no space in /tmp. Turns out that most Linux distros have ramdisk baesd tmpfs (temporary file system in RAM which is mounted at /tmp) and there is no separate partition which could be extended. /tmp is mounted usually by using 50% of available RAM.

Install NDK using Android Studio’s built-in SDK manager ->not so convenient
a) Extend /tmp
I edited my fstab as root, using this command :

I appended this line to my fstab

none /tmp tmpfs size=8G 0 0 

Note: If no such line exists, add above line at end of fstab. If any such line exists, it means you had already extended your /tmp and it was still insufficient. So, only change the «size» value, by raising it by a few GBs.
Then I rebooted. Once I did, my /tmp was extended to 8GB size. For development purposes, I guess we should readily extend our /tmp because we will have to do it anyway some time later. Size of /tmp is not dependent on free space in our hard disk (whether virtual or physical).

b) run NDK install again
I ran the NDK install from within AndroidStudio again. It had to download the NDK zip afresh. Unfrotunate that there is no resume/recheck function to resurrect broken installs. My download speed was slow, so I minimized the virtual linux’s window and continued to read news. Later, I guess memory/page swapping occurred. The download failed. I restarted Linux and restarted NDK install the same way. This time, I let the virtual Linux machine stay on foreground. NDK installed fine with this log :

Manual NDK install in Linux (preferable) I am amazed that official Android dev section did not bother indicating exact install location of Android NDK. Android Studio looks for NDK at:

Источник

How to install Android NDK on Ubuntu Linux ?

The Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++. For certain types of apps, this can help you reuse code libraries written in those languages.

To install and configure the NDK, follow these steps:

Download android ndk Linux 64 bit from http://developer.android.com/ndk/downloads/index.html , when we written this post, the latest Android version is R23B, which we downloaded and copied to /home/myuser/Android directory. Now, Lets extract this zip as,

$ unzip android-ndk-r23b-linux.zip

This will extract as “Extracting android-ndk-r23b” into folder “android-ndk-r23b” in ~/Android directory. When uncompressed, the NDK files are contained in a directory called android-ndk- . You can rename the NDK directory if necessary and you can move it to any location on your computer.

Export the NDK path into environment variables,

$ export PATH=$PATH:/home/myuser/Android/android-ndk-r23b

OR You can also edit your ~/.bashrc file and append above line to add NDK permanently to your path to avoid typing above command always.

Check if ndk-build is added to environment,

$ which ndk-build /home/myuser/Android/android-ndk-r23b/ndk-build

Sometimes, you may need to set NDK_HOME evnvironment variable which you can do the same way as above,

$ export NDK_HOME=/home/myuser/Android/android-ndk-r23b

Источник

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