Installing a specific toolchain in android NDK - android

I am trying to build a project that requires
arm-linux-androideabi-4.8
How do I specifically install arm-linux-androideabi-4.8 alone?

You can't install a subset of the NDK. It's only available as a monolithic package.

download android-ndk-r14b-linux-x86_64.zip
to download type this
cd /
wget https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip
to unzip
unzip android-ndk-r14b-linux-x86_64.zip
to build
cd /android-ndk-r14b
cd build/tools
export TOOLCHAIN=/android-toolchain
./make_standalone_toolchain.py --arch arm --api 19 --install-dir /android-toolchain

Related

Install Android NDK on Jenkins

I wanted to install the Android NDK on my Jenkins. What I normally do to install components is execute the command
android list sdk --all
and
android update sdk -u -a -t <package number>
Unfortunately android list sdk --all is not showing the NDK, CMake and LLDB sdks that I need.
Why those sdks are not showing on the sdks list?
How can I install the NDK on my Jenkins?
Thanks for the help
Instead of using the command line, you can simply download the NDK per your machine and unzip it to a directory wherever you like. NDK can be downloaded at: https://developer.android.com/ndk/downloads. All the components, e.g. NDK, CMake and LLDB are shipped inside.
Update: If you really want to go for command line approach, command sdkmanager (under directory: <your-path>/sdk/tools/bin) is the way to go.
E.g. List installed and available packages
./sdkmanager --list
To install NDK directly use below.
./sdkmanager "ndk-bundle"
./sdkmanager "lldb;3.1"
./sdkmanager "cmake;3.6.4111459"

Android SDK on Alpine - adb No such file or directory

I'm trying to build an Alpine image containing the Android SDK - specifically, the platform-tools package.
My Dockerfile does the following:
Installs Java and sets JAVA_HOME (needed for Android).
Downloads the Android SDK tools from Google.
Unzips the package.
Sets ANDROID_HOME. Also sets PATH so the sdkmanager executable can be used.
Installs platform-tools using sdkmanager.
Adds platform-tools to PATH.
platform-tools contains an executable named adb, but for some reason it cannot be seen. Running adb returns:
bash: /android-sdk/platform-tools/adb: No such file or directory
Here is my Dockerfile:
FROM alpine:latest
# Install bash and java
RUN apk update
RUN apk add bash openjdk8
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ENV PATH="$PATH:$JAVA_HOME/bin"
# Download Android SDK and set PATH
RUN mkdir /android-sdk
RUN wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && unzip *.zip -d /android-sdk && rm *.zip
ENV ANDROID_HOME="/android-sdk"
ENV PATH="$PATH:$ANDROID_HOME/tools/bin"
# Install platform-tools
RUN yes | sdkmanager "platform-tools"
ENV PATH="$PATH:$ANDROID_HOME/platform-tools"
RUN adb version # throws error: adb not found
I've looked at this question but the problem should be fixed with platform-tools v24.0 and higher.
Alpine uses musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements.
adb is compiled with glibc, so it won't be able to run in Alpine, which usually results in the error: No such file or directory.
You can verify that a file is compiled with glibc by running file <path to file> | grep "interpreter /lib64/ld-linux-x86-64.so.2".
This may help, although the Gradle daemon randomly crashes for me on Alpine Linux when using the compatibility layer.
gcompat is the go-to compatibility layer for Alpine users.
apk add gcompat
After that you run your binaries as normal.
Source: https://wiki.alpinelinux.org/wiki/Running_glibc_programs
You can install android-tools like so:
RUN apk add \
android-tools \
--repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
The key is to set the --repository as shown, as it's only in the edge testing repo.
I don't think it includes the whole SDK, so may need to download and unzip as well for other tools. I don't know if this will handle everything you want, but adb prints a help document at least.

Travis: how to know android sdk/ndk path?

My android project is built with Ant and i have to edit ant.properties manually file to pass sdk.path variable pointing to android sdk directory. i'm going to change it to get sdk path from environment variable to make build possible on Travis CI. What is android sdk variable for this?
Also i have some jni code to be built with android ndk, so the similar question - what is env variable for android ndk on Travis?
Don't use the Travis's Android support; it uses the old 'android' CLI instead of the new sdkmanager CLI that supports installing the NDK. Do something like:
before_install:
- cd $HOME
- wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O $HOME/android-sdk.tgz
- mkdir android
- unzip android-sdk.tgz -d android/sdk
- export PATH=$PATH:$HOME/android/sdk/tools:$HOME/android/sdk/tools/bin
- cd build/<your-build-directory>
And then in the 'install' section:
install:
- echo y | sdkmanager 'ndk-bundle'
- echo y | sdkmanager 'cmake;3.6.3155560'
- export ANDROID_HOME=$HOME/android/sdk
- export ANDROID_NDK_HOME=$HOME/android/sdk/ndk-bundle
You can use the sdkmanager to install anything else you need. The benefit over the other answer is that this will grab the latest version of the NDK.
Finally, then you can set the environment variables ANDROID_HOME and ANDROID_NDK_HOME, and pass it to your specific environment.
Hope it helps.
Travis seems to provide Android support in beta. Android SDK can be found in /usr/local/android-sdk. However it seems that Android NDK is not provided and can't be found in /usr/local/android-ndk. The simple (and expensive walkaround for Travis) is to download/extract/use it right while building like this:
before_script:
- export NDK_VERSION=r10e
- curl -L http://dl.google.com/android/ndk/android-ndk-${NDK_VERSION}-linux-x86_64.bin -O
- chmod u+x android-ndk-${NDK_VERSION}-linux-x86_64.bin
- ./android-ndk-${NDK_VERSION}-linux-x86_64.bin > /dev/null
- rm android-ndk-${NDK_VERSION}-linux-x86_64.bin
- export ANDROID_NDK_HOME=`pwd`/android-ndk-${NDK_VERSION}
- export PATH=${ANDROID_NDK_HOME}:${PATH}
Feel free to comment this solution if you have a better one.
You can export the Android variables using this command as well as Clive Lee's method
env:
global:
- ANDROID_HOME=$HOME/android/sdk
- ANDROID_NDK_HOME=$HOME/android/sdk/ndk-bundle

Build PJSIP for Android on Windows?

I am beginner with Android and I have to make a voip app and after searching I found that the better opensource library for that is PJSIP.
I download the below things to build the PJSIP library:
PJSIP from here
Android NDK
SWIG
...But I don't know how to start. I checked this link for the official PJSIP website but I didn't make any progress.
Which Directory do I have to put the Android NDK into?
How to use SWIG to build the PJSIP?!
which Directory i have to put the Android NDK ?
Put it where you want, later you will setup the path to it
$ export ANDROID_NDK_ROOT=/path_to_android_ndk_dir
how to use SWIG to build the PJSIP ?!
You don't need SWIG to compile the PJSIP sources, it's needed only if you want to build and and run the sample application PJSUA.
Updated
The steps to build sources are
Download sources from PJSIP site. Pay attention if you will compile on Windows machine download .zip file, if on Unix machine (including OS X) then download .bz2 file.
Go to pjlib/include/pj/ from the downloaded sources. Create (or overwrite) a file called config_site.h. Copy the following code snippet
#define PJ_CONFIG_ANDROID 1
#include <pj/config_site_sample.h>
Open Cmd or Terminal
Go to pjsip root folder (the downloaded sources)
$ cd /path/to/your/pjsip/dir
Export bash var ANDROID_NDK_ROOT as a environment variable. Variable value should be the path of android ndk directory.
$ export ANDROID_NDK_ROOT=/path_to_android_ndk_dir (Unix)
SET ANDROID_NDK_ROOT=/path_to_android_ndk_dir (Windows)
Perform build for target armeabi
$ ./configure-android
If you need to perform build for
target arm64-v8a do $ TARGET_ABI=armeabi-v8a ./configure-android --use-ndk-cflags
target armeabi-v7a do $ TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags
target x86 do $ TARGET_ABI=x86 ./configure-android --use-ndk-cflags
Compile sources
$ make dep && make clean && make

android NDK - make standalone toolchain fails

I tried to make a standalone Android NDK toolchain on Linux 64 bit:
~/build/android-ndk-r9/build/tools $ ./make-standalone-toolchain.sh --platform=android-14 --ndk-dir=/home/user/build/android-ndk-r9 --system=linux-x86_64 --install-dir=/home/user/build/android-14-toolchain
Auto-config: --toolchain=arm-linux-androideabi-4.6
Copying prebuilt binaries...
No files are actually copied. Something goes wrong. The NDK ist the latest release r9.
How can I run the script so that the files get copied to the installation directory?
A suggestion: Use the --verbose option if you haven't already done so; it will tell you in which stage the error occurs.
Here are the options I ran to make a standalone toolchain targeting android-14 and arm-linux-androideabi-4.7
sudo sh make-standalone-toolchain.sh --verbose --toolchain=x86-4.7\
--install-dir=/project/arm-cc --ndk-dir=/project/android/ndk/android-ndk-r9\
--platform=android-14

Categories

Resources