Installing Python-For-Android Linux Ubuntu, Build Errors - android

I trying to build a test project just to see if the installation works but I get this error almost instantly.....
/home/kivy/Android/sdk/platform-tools/tools/android
I have installed Android Studio and ran updates. I installed the 14(android 4.0) tools needed. I downloaded the NDK and even though Android Studio created a new Android folder with folders like tools, platform, platform-tools, etc I still downloaded the standalone folder Android-Linux (r24.4.1).
Android-Linux and the NDK are sitting at home/documents/sdk_ndk/...
The Android folder created by Android Studio is sitting at home/Android
Android Studio itself is with the NDK and Android-Linux folders.
.bashrc has...
export ANDROIDSDK=$HOME/Documents/sdk_ndk/android-sdk-r24.4.1
export ANDROIDNDK=$HOME/Documents/sdk_ndk/android-ndk-r13b
export ANDROIDAPI="14"
export ANDROIDNDKVER="r13b"
I've even tried....
export ANDROIDSDK=$HOME/Android/sdk
export ANDROIDNDK=$HOME/Documents/sdk_ndk/android-ndk-r13b
export ANDROIDAPI="14"
export ANDROIDNDKVER="r13b"
Build commands are....
p4a apk --private ~/Desktop/testapp --package=org.example.myapp --name "testapp" --version 0.1 --bootstrap=sdl2 --requirements=python2,kivy
When I set this...
export ANDROIDSDK=$HOME/Documents/sdk_ndk/android-sdk-r24.4.1
Api target 14 is not found.
When I set this...
export ANDROIDSDK=$HOME/Android/sdk
I don't get an api error but I get the path error.
not found /home/kivy/Android/sdk/platform-tools/tools/android
I've even tried...
export ANDROIDSDK=$HOME/Android/sdk/tools
export ANDROIDSDK=$HOME/Android/sdk/platform-tools
-------Update-------------------
I've added the '"' around paths.....
export ANDROIDSDK="$Home/Documents/sdk_ndk/android-sdk-r24.4.1"
#export ANDROIDSDK="$Home/Android/sdk"
export ANDROIDNDK="$Home/Documents/sdk_ndk/android-ndk-r13b"
export ANDROIDAPI="14"
export ANDROIDNDKVER="r13b"
And now get and error saying it cant find /tools/android. This is strange because there is an Android file in the tools folder. It doesn't have the .sh extension, but it's there.
Here's the whole terminal output......
kivy#kivy-VirtualBox:~$ p4a apk --private ~/Desktop/testapp --package=org.urchatty.com --name "testapp" --version 0.1 --bootstrap=sd12 --requirements=python2,kivy
[INFO]: This python-for-android revamp is an experimental alpha release!
[INFO]: It should work (mostly), but you may experience missing features or bugs.
[INFO]: Will compile for the following archs: armeabi
[INFO]: Found Android API target in $ANDROIDAPI
Traceback (most recent call last):
File "/usr/local/bin/p4a", line 9, in <module>
load_entry_point('python-for-android==0.4', 'console_scripts', 'p4a')()
File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 754, in main
ToolchainCL()
File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 343, in __init__
getattr(self, command_method_name)(unknown)
File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/toolchain.py", line 87, in wrapper_func
user_ndk_ver=self.ndk_version)
File "/usr/local/lib/python2.7/dist-packages/pythonforandroid/build.py", line 226, in prepare_build_environment
android = sh.Command(join(sdk_dir, 'tools', 'android'))
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1029, in __init__
raise CommandNotFound(path)
sh.CommandNotFound: /Documents/sdk_ndk/android-sdk-r24.4.1/tools/android
kivy#kivy-VirtualBox:~$
---------Update-------------------------
Seems like my paths in the bashrc had to be written as.... "/home/kivy/....". I didn't get far before another error hit me....
kivy#kivy-VirtualBox:~$ p4a apk --private $HOME/code/myapp --package=org.example.myapp --name "My application" --version 0.1 --bootstrap=sdl2 --requirements=python2,kivy
[INFO]: This python-for-android revamp is an experimental alpha release!
[INFO]: It should work (mostly), but you may experience missing features or bugs.
[INFO]: Will compile for the following archs: armeabi
[INFO]: Found Android API target in $ANDROIDAPI
[INFO]: Available Android APIs are (4, 19)
[INFO]: Requested API target 19 is available, continuing.
[INFO]: Found NDK dir in $ANDROIDNDK
[INFO]: Got NDK version from $ANDROIDNDKVER
[INFO]: Using Google NDK r13b
[INFO]: Found virtualenv at /usr/local/bin/virtualenv
[WARNING]: ndk_platform doesn't exist: /home.kivy/Documents/android-ndk-r13b/platforms/android-19/arch-arm
[WARNING]: Could not find toolchain subdirectory!
[WARNING]: Could not find any toolchain for arm-linux-androideabi!
[WARNING]: Missing executable: autoconf is not installed
[WARNING]: Missing executable: automake is not installed
[WARNING]: Missing executable: libtoolize is not installed
[ERROR]: python-for-android cannot continue; aborting
kivy#kivy-VirtualBox:~$

EL3PHANTEN's answer made the difference.
# $ANDROIDSDK/tools/android update sdk --no-ui --filter 2,3,15
Using the terminal instead of the Manager seemed to help. The files downloaded for the SDK were actually less. They were much larger using the SDK Manager UI.
The other trick was in the bashrc. Paths had to start with "/" only.
"/home/kivy/Documents/...."
Finally, p4a is doing it's thing. The Kivy Website really should update it's Docs to include what EL3PHANTEN purposed. Also, the path styles used in the documents...
export ANDROIDSDK="$HOME/Documents/android-sdk-21"
export ANDROIDNDK="$HOME/Documents/android-ndk-r10e"
export ANDROIDAPI="14" # Minimum API version your application require
export ANDROIDNDKVER="r10e" # Version of the NDK you installed
That doesn't cut if for some reason. I could have save myself a lot of bandwidth and time if I would have gotten help from EL3PHANTEN earlier instead of doing everything on the Kivy Website as is.
The only thing on my mind now is, what error will I run into next? Obviously the Docs on this stuff isn't 100 percent.

As your error says, it cannot find android which should be in your sdk/tools folder. So eiter your ANDROIDSDK variable is wrong, or your tools folder does not contain android
If its the path variable, check the path of your sdk.
If your android executable is missing, try following steps when updating the sdk.
You probably updated everything, without choosing packages.
That means your tools folder might be empty now.
What you can do now, is to eiter find the packed tools folder in /home/kivy/Android/sdk/platform-tools/temp, or delete the whole sdk folder and try again.
The correct way to update the android-sdk is this:
(the following procedure takes less time, since you dont need all the packages)
First download and unpack the sdk.
Since we dont need all the packages, we first want a list of available packages.
# ANDROIDSDK="$HOME/Android/sdk"
# $ANDROIDSDK/tools/android list sdk
Now we get a list of packages.
We need to install the build_tools and the platform_tools, which in my case show as 2 and 3. Also we need SDK Platform Android 4.0.3, API 15 since we chose API version 15. This package is incidentally also shown as 15 in my case. (or whatever API you want)
So we add the filter 2,3,15.
Be sure NOT to install Android SDK Tools which is shown as 1 in my case. This will empty the tools folder, and we dont want that.
Note
Your filter might be different, then explained above.
Then run this command to install the packages you chose:
# $ANDROIDSDK/tools/android update sdk --no-ui --filter 2,3,15

Related

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.

Aidl not found,but it already exists

if i type in buildozer -v android release.and not in root.
Check that aidl can be executed
build-tools folder not found /home/m/.buildozer/android/platform/android-sdk-20/build-tools
Search for Aidl
Aidl not found, please install it.
but if i type in aidl
enter image description here
I have been having this error for a long time and multiple instances, even after trying to reinstall Aidl, reinstall buildozer, and deleting .buildozer project file.
Problem
This was caused by installation of wrong/outdated/mixed android-sdk build tools at;
~/.buildozer/android/platform/android-sdk/build-tools
Note:
Buildozer can only build without Aidl error if only the latest/correct android-sdk build-tools are installed.
Solution
Navigate to android-sdk build-tools path as shown below;
cd ~/.buildozer/android/platform/android-sdk/build-tools
Check the latest build tool you have, type;
ls
You should see a list of folders with names 29.0.0, 29.0.2, or any other folders.... this can be different. Note the latest version, eg (from example above is 29.0.2)
If this folder is empty proceed.
Type;
sudo rm -Rf *
Then run the following command;
cd ~
On the command below, replace "build-tools;29.0.0" version flag with your latest version (Noted above from ls command). eg ("build-tools;29.0.0" to "build-tools;29.0.2"). Use the command as it is if the build-tools folder was empty.
Hit enter to download.
~/.buildozer/android/platform/android-sdk/tools/bin/sdkmanager "build-tools;29.0.0"
Navigate to your Buildozer build project folder, run;
buildozer android debug
I hope this will help you solve the problem.

p4a Could not find `android` or `sdkmanager` binaries in Android SDK. Exiting

I spend hours struggling on this issue and I feel dumb as f***. I followed this doc, installed everything I needed until the effective building step:
p4a apk --debug --private $HOME/Documents/Code/Python/app_kivy/identifier/main.py --package=org.example.myapp --name "My application" --version 0.1 --bootstrap=sdl2 --requirements=python2,kivy
[INFO]: Will compile for the following archs: armeabi
[INFO]: Found Android API target in $ANDROIDAPI
[ERROR]: Could not find `android` or `sdkmanager` binaries in Android SDK. Exiting.
Here is the end of my .bashrc
# Adjust the paths!
export ANDROIDSDK="$HOME/Android/Sdk/"
export ANDROIDNDK="$HOME/Apps/android-ndk-r16b/"
export ANDROIDAPI="19" # Minimum API version your application require
export ANDROIDNDKVER="r16b" # Version of the NDK you installed
I tried several paths variants, tried both the full Android Studio and the ‘just the command line tools’ methods of the doc, nothing. NB android and sdkmanager are installed in different folders (resp. tools and tools/bin). I am pretty sure that I am missing something in the .bashrc but what am I missing?
Thanks in advance for any insight
This p4a error message is less specific than it implies. $ANDROIDSDK need not even be a valid path to produce this error. That in mind, you should first check that it has even been exported properly by running the command echo $ANDROIDSDK. If you don't see the expected path printed out, you'll need to run your .bashrc script again the way you normally would.
If you do see the expected path, then the most likely problem is that the contents of $HOME/Android/Sdk/ aren't what p4a was expecting. For that I unfortunately can't offer a suggestion of what might be wrong without knowing what the contents are.

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

NDK - Error trying to generate a build.xml file for Hello-jni

I just installed Android NDK, r5b, and while trying to follow the steps from Exploring the hello-jni Sample, on the command line I receive the error:
MacBook-2:~ mvermant$ cd ndk/samples/hello-jni
MacBook-2:hello-jni mvermant$ android update project -p . -s
-bash: android: command not found
I'm using Eclipse Helios release 2 with Android SDK r10 and ADT 10.0.0 on MAC 10.6.6. I have also checked to have GNU Make 3.81, and installed GNU Awk(though I am not sure it's in the right place).
I've searched a lot, and seems there might be a class path missing somewhere, but I can't figure out where exactly and what to do to fix it.
You should make sure the tools directory of your android-sdk is on your (shell) path.
Something like:
export PATH="/path/to/sdk/tools:$PATH"
before you execute your command.
In general you will also need two other directories to be on your path:
/path/to/sdk/platform-tools - for adb and other android sdk tools
/path/to/ndk - for ndk-build and ndk-gdb, which are ndk tools
You can also do some setup so that you don't have to run these commands every time you open Terminal.

Categories

Resources