Compile in Fedora and run on Android - android

Is it possible to compile a c code in Fedora and to run it on Android with gcc? I tried to compile using gcc file.c -o f1 and it didn't work. Any seggustions? I was unable to execute it with ADB tool.

If your c code is run in terminal, you can simple cross compile it and push the executable file to your phone by using ADB tools.
get a cross compiler
download a cross compiler, for example:
http://www.mentor.com/embedded-software/sourcery-tools/sourcery- codebench/editions/lite-edition/
you can build android develop environment from:
http://source.android.com/source/building.html
use arm-eabi-gcc for compiling your c code , generate executable file ie. a.out
adb push a.out /sdcard, chmod 777, then you can run it from adb shell

Related

Manually compile C code with command line to run on Android

I want to compile some C code manually in order to run it on Android. The C code can be as simple as this hello world program:
#include<stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
The result should be an executable binary file, which I can run with adb like this:
adb push exename /data/local/tmp
adb shell chmod 777 /data/local/tmp
adb shell /data/local/tmp
I am able to create such an executable with Android Studio and the NDK. To better understand the compiling process I want to know how I can manually compile the code with the command line. I know that there are different ABIs that are compiled with different tools, but the process should still be the same.
I am pretty sure it is possible as the NDK includes multiple executables like aarch64-linux-android-as, which allows me to compile Assembly to an executable. Unfortunately, I could not find any documentation of all tools included in the NDK in order to find out which is the correct tool myself.
The question now is if someone knows which tools of the NDK I have to use in order to create an executable from my provided C code. If the process for compiling multiple .c files into one binary is different from gcc I would also appreciate the process of compiling multiple files.
Thank you very much in advance!
~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=aarch64-linux-android21 helloworld.c -o helloworld

How to convert .py to APK file using Python for Android on Windows?

I am working on Kivy framework. I have some sample of Kivy which has .py extension which I want to convert to .apk files. I want to check whether these working on Android or not.
I have some information about this. We have two ways to build an .apk file:
Using Python for Android,
Using Buildozer.
But Buildozer is only supported on Linux. I thought it has some problems on Windows.
Hence, I want to use Python for Android. But I have no idea how to approach this one.
Have anyone tried this one.
You can use VirtualBox Get it here and any Linux Distribution such as Ubuntu Ubuntu.
After installing Ubuntu to your Virtualbox you can use below commands:
Run these commands on Terminal
sudo apt install git
sudo apt install python3-pip
git clone https://github.com/kivy/buildozer.git
cd buildozer
sudo python3 setup.py install
Now, navigate to your project directory using cd (or) goto your Project directory, RightClick -->select 'Open in terminal' and in Terminal type:
buildozer init
Above Command creates a buildozer.spec file controlling your build configuration. You should edit it appropriately with your app name, file extensions used in the project, external dependencies etc. After configuring your buildozer.spec fille run below commands:
sudo apt update
sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev
pip3 install --user --upgrade Cython==0.29.19 virtualenv # the --user should be removed if you do this in a venv
sudo pip3 install cython #(optional) If you got any Error as Cython not Found, use this
which buildozer
Above command is to check buildozer was added to your PATH), If no results found, add the following line at the end of your ~/.bashrc file--> export PATH=$PATH:~/.local/bin/
buildozer appclean
buildozer android debug
If you are asked for any licence agreement type y and click Enter
Once this process completes you will get a .apk file in your project directory bin/yourapp.apk
Kivy themselves used to have a virtual machine prepared with everything installed ready to go!
For some reason they stopped, now you have to install the Virtual Machine yourself.
You can see how to do this here
here is a link you can find everything that is related to getting .Apk files
https://python-for-android.readthedocs.io/en/latest/quickstart/#usage

Android lib ijkplayer load https url

I am using ijkplayer in my android app that I compile using
compile 'tv.danmaku.ijk.media:ijkplayer-java:0.4.5'
compile 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.4.5'
It works perfectly loading http urls but if I try to load https urls I get this error
https protocol not found, recompile FFmpeg with openssl, gnutls, or securetransport enabled.
and can't load my video. I don't know if it makes any difference but the url I am trying to load is a .m3u8 but if it is http works fine.
How can I recompile ffmpeg in this lib?
Hi Petro i am not proffesional but hope this tutorial would help.
You have to compile ijkplayer with openssl support to open https links,
to do that follow this steps:
Grab latest version of IjkPlayer from github:
$ git clone https://github.com/Bilibili/ijkplayer.git
Open just downloaded folder ijkplayer
Remove symlinks to module.sh and create symlink to module-lite.sh
$ cd config
$ rm module.sh
$ ln -s module-lite.sh module.sh
Do initialisation of OpenSSL (getting ready to download and compile openssl first)
$ cd ..
$ ./init-android-openssl.sh
Make sure you have pointed for your SDK and NDK path.
(NDK r10e preffered - I am not sure if SDK is needed but just in case i did exported it)
NOTE: make sure you have changed your path properly that is only example of path what i have used.
export ANDROID_SDK="/home/ZiomusGorliczanin/SDK"
export ANDROID_NDK="/home/ZiomusGorliczanin/NDK"
Open IjkPlayer/android/contrib folder and fire up compile-openssl.sh clean and all command (that will compile openssl for all processors).
$ cd android/contrib
$ ./compile-openssl.sh clean
$ ./compile-openssl.sh all
Compilation might take a while 10 min.
Compile FFMpeg with OPENSSL for all processors:
$ cd android/contrib
$ ./compile-ffmpeg.sh clean
$ ./compile-ffmpeg.sh all
Finally compile IjkPlayer with all above as a liblary.
$ cd ..
$ ./compile-ijk.sh all
After all this steps you should have liblaries in those folders (Three *.so files):
ijkplayer/ijkplayer-armv5/src/main/libs
ijkplayer/ijkplayer-armv7a/src/main/libs
ijkplayer/ijkplayer-arm64/src/main/libs
ijkplayer/ijkplayer-x86/src/main/libs
Try to import gradle project to your Android Studio and Run Ijk-Example for testing.
If you got this error
./compile-ijk.sh profiler build: NO
It is because of security policy of Apple in MacBook, so there is alternative solution for this to go to Apple menu-->System Preferences-->Security & Policy and Allow anyway it will prompt there.

tinyalsa sh: ./tinypcminfo: No such file or directory

tinyalsa elf failed to run on android shell, anybody know what is wrong with it ?
I am new to android, :-)
here are my steps:
1. download tinyalsa source code to a ubuntu 10 vm, compile it with arm-linux-gnueabi-gcc
2. adb push xx\tinypcminfo /data/local/tmp
3. adb shell -> cd /data/local/tmp ->chmod 777 tinypcminfo
4. ./tinypcminfo
5. error happened

Android link .so for command line executable?

I am developing a cross-platform library, and am trying to test on Android. I have compiled my library with ndk-build, and am trying to compile and run a command-line test fixture we have for the library.
I use adb push to put the test fixture and .so in /data/local/tmp and chmod both to 777.
Then I use adb shell to run the test, but get the following error
shell#android:/data/local/tmp $ ./mytest
./mytest
link_image[1936]: 7289 could not load needed library 'libtconfig.so' for './mytest' (load_library[1091]: Library 'libtconfig.so' not found)CANNOT LINK EXECUTABLE
Both mytest executable and libtconfig.so are in the same directory. I would have assumed it looks in "." directory first?
I found I can add the path /data/local/tmp to LD_LIBRARY_PATH and it will work, however when using adb shell commands in a script, each "adb shell" is a new instance, so LD_LIBRARY_PATH is reset

Categories

Resources