I'm trying to compile ffmpeg for Android using this guy script (https://github.com/guardianproject/android-ffmpeg) because it looked like the simplest and the whole NDK is really not my area of expertise.
So let's see what I've done so far:
Downloaded and installed a fresh Ubuntu 12.04 LTS from: http://www.ubuntu.com/download/desktop in a VirtualBox. (had some little problems with video but a few updates later in the terminal ubuntu is up and running)
installed the Android SDk and downloded/unzipped the NDK into /Documents/ndk
I used those commands to install the compiler:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential
$ gcc -v
$ make -v
then sudo install git (or something like that to install git)
then git clone https://github.com/guardianproject/android-ffmpeg.git
then copied from the guys page building section
cd android-ffmpeg
git submodule init
git submodule update
NDK_BASE=/path/to/android-ndk ./configure_make_everything.sh
it mostly goes well until it says:
arm-linux-androideabi-gcc is unable to create an executable file C
compiler test failed
If you think configure made a mistake,.. blaah blahh blaah
I'm not sure what it means or where to go from here.
from this I did some chmod 777 on the folders to make sure stuff can be execute.
also from this I tried his script but without any luck.
help?
decompose what the script 'config_make_everything' is doing.. and run one step at a time...
https://github.com/guardianproject/android-ffmpeg/blob/master/configure_make_everything.sh
each step will create a file like 'config.log' where you can go to the tail and find more details about what went wrong finding the compiler.
When u start using the NDK, IMO, invest a bit of learn curve time going thru its ./doc directory and making sure that you have it integrated correctly. With NDK install, there are some samples. Build a few from CLI just to make sure that the ENV is correct and that the install is good, and that u have at least some idea of the build as a repeatable process. That will prove that you can do good 'cross compiles' with the build tools. Then you can return to guardian.ffmpeg stuff.
IMO - there is alot going on with an NDK build of this project and getting it all to build without understanding any of the underlying configuration / build stack would require lots of luck.
Related
I would like to compile Android Apps with SDK 23.0.3 as a user on CentOS. Unfortunately, everytime build-tools/23.0.3/aapt is run, it returns
bash: build-tools/23.0.3/aapt: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
The problem seems to be that 32 bit libraries need to be installed. If I have sudo rights (on Ubuntu), I can run sudo apt install libc6-i386 lib32stdc++6 lib32gcc1 (like described in CentOS 64 bit bad ELF interpreter), but unfortunately, I do not have sudo on the machine where I would like to compile.
I assumed that I could get the used libraries (like described in https://www.cs.virginia.edu/~dww4s/articles/ld_linux.html) and then replace the used libraries by setting LD_LIBRARY_PATH (like described in http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html). I extracted the libraries by
ldd ../androidsdk/build-tools/23.0.3/aapt | \
grep "i386" | awk '{print $3}' | \
while read file
do cp $file .
done
and copied them to /home/test. Then I ran export LD_LIBRARY_PATH=/home/test, but then aapt returns the same error.
Another thing I tried was getting and extracting the libraries (on Ubuntu):
apt-get download libc6-i386 lib32stdc++6 lib32gcc1
for file in *.deb
do dpkg -x $file .
done
And aftwards setting the LD_LIBARY_PATH to /home/test/lib:/home/test/lib32, which also did not work.
This could be reproduced by a docker container: running docker run -it ubuntu bash and then
apt update && apt install git unzip wget openjdk-8-jdk
cd home/
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip
cd tools/
yes | bin/sdkmanager --install "build-tools;23.0.3"
cd ..
For setup. Then, build-tools/23.0.3/aaptreturns
bash: build-tools/23.0.3/aapt: No such file or directory
which is the same problem as in the CentOS (Can not run android/sdk/build-tools/23.0.2/aapt): A 32 bit library is missing.
Can someone tell me what would be the correct way to add the libraries?
EDIT
Since the interpreter, normally /lib/ld-linux.so.2 starts interpreting files, it needs to be replaced. If I manually extract all .so-files like described above, put them in lib/ and run
LD_LIBRARY_PATH=$(pwd)/libs libs/ld-linux.so.2 build-tools/23.0.3/aapt
the aapt-command is executed correctly. Unfortunately, this is not enough for building:
LD_LIBRARY_PATH=/nfs/user/do820mize/workspaces/dissworkspace/androidsdk/libs /nfs/user/do820mize/workspaces/dissworkspace/androidsdk/libs/ld-linux.so.2 ./gradlew --init-script ../init.gradle assemble
returns the ELF-error again, since the gradle-wrapper (and Java and so on) are 64 bit binaries.
glibc.i686 is available from the base repository:
$ yum whatprovides ld-linux.so.2
glibc-2.17-260.el7.i686 : The GNU libc libraries
Repo : base
Matched from:
Provides : ld-linux.so.2
in case it should not be possible to have basic dependencies provided, that cluster is useless. of course it would need to be installed on all nodes; the chances that it would break something are rather slim, while having the same version number for the x86_64 version of the glibc library.
The problem is, that the header of the elf file (e.g. aapt) contains a link to the interpreter (e.g. /lib/ld-linux.2.so). This link needs to be replaced for execution, but only for the 32 bit elf-binaries. Gradle and Java still need to be executed with their regular 64 bit Interpreter. Since the processes that are called (e.g. aapt) are sub processes, calling another interpreter directly is not possible.
One possible solution is using patchelf (https://nixos.org/patchelf.html). First, it needs to be compiled (even if they say, that there is a binary, I did not find it):
wget https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2
tar -xvf patchelf-0.9.tar.bz2
cd patchelf-0.9/
./configure && make
Afterwards, you'll find an patchelf executable in src/ (which was a rather surprising location for me).
Just add this to the path by PATH=$(pwd)/src:$PATH, get the ld-linux.so.2 from your system, save it to $MY_PLACE/libs/ld-linux.so.2, cd to your Android SDK and execute
patchelf --set-interpreter $MY_PLACE/libs/ld-linux.so.2 build-tools/23.0.1/aapt
patchelf --set-interpreter $MY_PLACE/libs/ld-linux.so.2 build-tools/23.0.1/aidl
patchelf --set-interpreter $MY_PLACE/libs/ld-linux.so.2 build-tools/23.0.1/zipalign
Then, you'll need to set the library path, e.g. by export LD_LIBRARY_PATH=$MY_PLACE/libs/. Afterwards ./gradlew assemble is running fine (for exactly this build tools version).
While this solution works, you'll need to edit every binary (which may be needed later) manually. I assume that there is some magic in multiarch systems which determines which interpreter to use, the 32 or 64 bit one (ldd will return different pathes for the interpreter depending on the file). It would be a better solution to make use of this magic in order to run 32 bit executables without root. Therefore, I'll accept a solution which make it possible to run builds by just changing environment variables and without tampering with the executables.
This page documents running an old version (1.8.4) of mercurial but says
"(later versions need an unavaliable python module named grp)"
This is the way I did it (but am still interested to hear of alternative ways) using an Ubuntu 16.04 machine and a intel 64bit android emulator running on Windows 7, using mercurial 3.7.3
Using an Ubuntu system, follow these instructions for creating 2.7 version of python capable of running hg.
Copy python onto android device into an app files directory (so it can be executed)
on windows host
adb push python279.x86_64 /sdcard
adb -e shell
on android device
cd /data/user/0/$SOMEAPPDIR/files
cp -Rav /scard/python279.x86_64 .
make python excutable
chmod +x python279.x86_64/bin/python2.7
set some env vars need to make python run on android
export LD_LIBRARY_PATH=/data/user/0/$SOMEAPPDIR/files/python279.x86_64/lib
export LD_PRELOAD=libffi.so:libbz2.so
export PATH=$PATH:/data/user/0/$SOMEAPPDIR/files/python279.x86_64/bin
Python should now be able to be run with python2.7
Build mercurial on Ubuntu host.
download mercurial 3.7.3
uz mercurial-3.7.3.tar.gz
cd mercurial-3.7.3 && make all
HOME=$PWD/dist make install
Make minor modifications
cd dist/mercurial-3.7.3/dist/lib/python/mercurial
rm *.so
cp pure/*.py .
Edit posix.py and delete the "import grp" line.
copy mercurial onto android device
on windows host
adb push dist /sdcard
adb -e shell
on android device
cd /data/user/0/$SOMEAPPDIR/files
cp /sdcard/dist .
alias hg to make it easy to use
alias hg='python2.7 /data/user/0/$SOMEAPPDIR/files/dist/bin/hg'
Hg should now be possible to use on android device.
It's even possible to clone remote repos but I also had to pass the --insecure flag to bypass ssl errors.
The answer made on "Feb 15 '17" works fine however there is one fairly big drawback.
This answer address this drawback and is intended to be used in conjunction with the previous answer.
The problem
This procedure:
rm *.so
cp pure/*.py .
removes the native libraries and uses the python 'pure' implementation of these libraries instead. This causes major performance problem when working with large repositories, especially on slower android devices.
The solution
Cross compiling mercurial with android ndk, produces native libraries that can be used on android.
I've added some helper scripts to a mercurial 4.8.2 fork to make cross compiling easier.
Linux instructions:
Clone the repo
hg clone https://bitbucket.org/hindlemail/hg-stable-android/
update to 331892efe015
hg update -r 331892efe015
Set these for environment variables with appropriate values:
provide location of android NDK
ANDROID_NDK="$HOME/Android/android-ndk-r13b"
specify build arch - (armeabi, x86, x86_64, arm64)
ARCH="armeabi"
specify target android sdk verison
PLATFORM="android-22"
specify output of cross compiled python.
(see answer from Feb 15 '17" for more info )
PYTHONDIR="/usr/local/android/install/python279.arm22"
Run crosscompile.sh
I am running a calabash-android test using docker. When I build the container with my docker file it seems like nothing executing except the first line. When I check whether ruby installed or not it shows the ruby version. Apart from that nothing is working. I am adding the docker file structure here.
############################################################
# Docker file to run Calabash for android automation testing.
############################################################
FROM ruby:2.1-onbuild
# install Android SDK dependencies
RUN apt-get install openjdk-7-jdk
# Install android sdk
RUN wget http://dl.google.com/android/android-sdk_r23-linux.tgz
RUN tar -xvzf android-sdk_r23-linux.tgz
RUN mv android-sdk-linux /usr/local/android-sdk
RUN rm android-sdk_r23-linux.tgz
# Install Android tools
RUN echo y | /usr/local/android-sdk/tools/android update sdk --filter platform,tool,platform-tool,extra,addon-google_apis-google-19,addon-google_apis_x86-google-19,build-tools-19.1.0 --no-ui -a
#install calabash-android
RUN gem install calabash-android
ENV ANDROID_HOME /usr/local/android-sdk
ENV ANDROID_SDK_HOME $ANDROID_HOME
ENV PATH $PATH:$ANDROID_SDK_HOME/tools
ENV PATH $PATH:$ANDROID_SDK_HOME/platform-tools
ENV JAVA_HOME /usr/lib/jvm/java-7-oracle
I have followed this link to implement the Docker file. Since this is for the first time I am setting up docker for android haven't the faintest idea whether it is proper or not. Someone please help to fix the issue. All kinda helps are appreciated.
I get this response for the docker build
Step 0 : FROM ruby:2.1-onbuild
# Executing 4 build triggers
Trigger 0, COPY Gemfile /usr/src/app/
Step 0 : COPY Gemfile /usr/src/app/ Gemfile: no such file or directory
First, as long as the docker build does not execute all the steps, it is perfectly expected to not see anything installed.
Second, the ONBUILD directives from the ruby:2.1-onbuild are made to complete the image when building a new one from said image.
As I mention before, you can try first using
FROM ruby:2.3.0
That does not require extra onbuild trigger.
I am facing a problem. I have to add a PDF reader support to my Android App (now I'm using Mupdf but I need to change it).
I found PDFium project (https://code.google.com/p/pdfium/) and I think it is what I need for my needs.
I haven't too much experience in Android and I've not been able to build it for Android, I've followed the build instructions from here https://code.google.com/p/pdfium/wiki/Build with no good results.
Could you give some hint or advice to achieve build this tool in Android?
Thank you in advance!!!
How to build?
I recommend building on Linux (virtual machine will suffice),
because Windows is officially not supported and there are many problems on newer versions of OS X.
You will need about 60 GB of free space.
install OpenJDK 8
$ mkdir ~/android_src && cd ~/android_src or select any other path
$ repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.1_r28
(detailed description available here)
$ repo sync and wait...
clone this repo (or download zip with its content)
replace makefiles in ~/android_src with corresponding makefiles from this repo
$ cd ~/android_src
$ source build/envsetup.sh
$ cd external/pdfium/fpdfsdk
$ lunch and select architecture
$ mma and wait ~5 minutes
library is available in ~/android_src/out/target/product/generic*/obj/lib/libmod*.so, copy it somewhere
$ rm -r ~/android_src/out before next build
It worked for me, but if doesn't work for you, try installing additional packages listed here.
Source
Build it within the AOSP
https://android.googlesource.com/platform/external/pdfium/
Use mm or mma instructions to build only the pdfium module
I've only successfully built the shared library but haven't take it into practice.
When I try to build my app, using Linux ElementaryOS (Ubuntu 12.04 (I think?)) I get thousands of errors saying:
rm: could not remove file (code EACCESS)
The results of the following show:
$ phonegap -v
3.5.0-0.20.4
$ cordova -v
3.5.0-0.2.4
$ ant -v
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed
Any suggestions? I've been battling through several errors for about a week now :(
Thanks in advance!
Update
Update I just changes the permissions of platforms/android too 777 (not a great solution I know). It's now giving me the following:
[Error: An error occurred while listing Android targets] { [Error: /var/www/ppl/app/platforms/android/cordova/build: Command failed with exit code 2] code: 2 } –
Okay, after much pain and anguish... I figured it out.
1). I installed ANT after I installed ionic/cordova/phonegap etc, the best order to install everything in is, java, ant, then cordova/phonegap/ionic.
2). I'm using 64-bit Ubuntu, if you are using the same then you need to install several android 32-bit libs.
3). I deleted the entire project (apart from my css, added js files and my html templates), created a new one using $ ionic start test-app then I ran $ ionic platform add android then ran $ ionic run android and it worked.
4). Make sure your paths are correct in ~/.bashrc mine look as followed:
export PATH=$PATH:/home/ewan/adt-bundle/tools
export PATH=$PATH:/home/ewan/adt-bundle/platform-tools
Here's a video that helped me, especially with the 32-bit libs. https://www.youtube.com/watch?v=zEQIwKK7YjY
Don't give up, it's worth it in the end. Best of luck!