Use linux command in Android NDK - android

I have build ffmpeg for android using NDK as mentioned here.
What I want to do is create a video file using image list as mentioned in here.
ffmpeg -i ffmpeg_temp/%05d.png -b 512 video2.mpg
I want to know how can I run this command in my C class file.
Thanks in advance.

read the ndk docs
edit your Android.mk so that you produce an executable 'ffmpeg'
run ndk-build
locate the 'ffmpeg' executable on your PC ( will be in folder like ' obj/local/armeabi-v7a/'
use adb to move 'ffmpeg' to the phone - you may have to mount something in order to do this
on phone, move 'ffmpeg' executable to /data/local/tmp
on phone, get a shell and invoke the CLI expression like you mention:
/data/local/tmp/ffmpeg -i ffmpeg_temp/%05d.png -b 512 video2.mpg
it should execute on the phone like it runs on any other linux system

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

Android 64bit terminal / rsync

I am trying to get my rooted LG G4 to rsync with my server. On the good old LG G2 it is running smoothly but the 64bit architecture throws errors at me.
I tried to come up with a solution from other sources (here and other sites) But it just goes on to the next file it cannot load correctly
The code I use is as follows:
export LD_PRELOAD=/system/lib64/libsigchain.so; export PATH=$PATH:/data/data/burrows.apps.busybox/app_busybox; export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/data/burrows.apps.busybox/app_busybox:/vendor/lib*:/system/lib*; /data/data/burrows.apps.busybox/app_busybox/rsync -v -E --delete -s -r -t -l --partial --size-only --rsh="/data/data/burrows.apps.busybox/app_busybox/ssh -y -i /keypath/ssh.key -p10022" user#homeip:/some/folder/ /local/folder
First it was the libsigchain.so 32/64bit error
Now it is this: CANNOT LINK EXECUTABLE DEPENDENCIES: "/system/lib/libsigchain.so" is 32-bit instead of 64-bit CANNOT LINK EXECUTABLE DEPENDENCIES: "libc.so" is 64-bit instead of 32-bit
Be it tasker, secure settings or terminal emulator ...
I would appreciate any suggestions.

Running unix commands on windows cmd

i am currently trying to learn how to develop apps for android mobile phones using PhoneGap. i was able to get this book titled "PhoneGap 2x mobile application development". ths book is really nice and self explanatory but the problem i have is when the author want to create d project via the command line, he was using Unix commands because he is running a Unix PC. I am running Windows and to follow his commands using the CMD is a bit hard for me because i dont understand all of his commands.
Below was what he wrote:
mkdir $PROJECT_HOME
cd $PROJECT_HOME
mkdir Android iOS www
cd $PHONEGAP_HOME/lib/android/bin
./create $PROJECT_HOME/Android/QuizTime com.phonegaphotshot.
QuizTime QuizTime
cd $PHONEGAP_HOME/lib/ios/bin
./create $PROJECT_HOME/iOS com.phonegaphotshot.QuizTime QuizTime
cd $PROJECT_HOME
mkdir www/cordova
cp Android/QuizTime/assets/www/cordova-2.2.0.js www/cordova/
cordova-2.2.0-android.js
cp iOS/www/cordova-2.2.0.js www/cordova/cordova-2.2.0-ios.js
cd Android/QuizTime/assets
rm –rf www
ln –s ../../../www
cd ../../../iOS
rm –rf www
ln -s ../www
cd ..
cd www
cp –r $YASMF_DOWNLOAD/framework .
mkdir images models views style
cd ..
cd Android/QuizTime/src/com/phonegaphotshot/QuizTime
edit QuizTime.java
Change "index.html" to "index_android.html"
Save the file.
cd $PROJECT_HOME/iOS/QuizTime
can someone tell me how to do this on the windows cmd. i know what mkdir is but i need a total description and if possible a translation following that if you were to do this on a windows cmd.
I forgot to mention one simple fact. You CAN NOT RUN the unix commands over Windows DOS/CMD
check this link. It gives direct co-relation between dos and unix commands. hope this helps.
http://www.tldp.org/LDP/intro-linux/html/app2.html
or better still, check this
http://www.yolinux.com/TUTORIALS/unix_for_dos_users.html
Once you get the different commands, guess it should not be hard for you to write it in DOS.
Note: The "create" command is part of phonegap/cordova apis..
Also, check this link: http://docs.phonegap.com/en/2.1.0/guide_command-line_index.md.html
Here is a snapshot of the code converted:
-- make directory ---
C:\> mkdir PROJECT_HOME
-- go to the directory you created ---
cd PROJECT_HOME
-- make directories inside ---
C:\PROJECT_HOME> mkdir Android
C:\PROJECT_HOME> mkdir iOS
C:\PROJECT_HOME> mkdir www
-- now navigate to the bin directory- ---
C:\PROJECT_HOME> cd \lib\android\bin
-- now you basically runn the create command, am hereby just putting in what you wrote ---
C:\PROJECt_HOME\lib\android\bin>create \PROJECT_HOME\Android\QuizTime com.phonegaphotshot.QuizTime QuizTime
----- do same for the ios------------
-------make dir for cordova -------
C:\PROJECT_HOME> cd www
C:\PROJECT_HOME\www> mkdir cordova
--then you have to copy the contents of one directory to another, to copy everyrthin in directory recursively, use xcopy-----------
C:\PROJECT_HOME> XCOPY Android\QuizTime\assets\www\cordova-2.2.0.js www\cordova\cordova-2.2.0-android.js
I know this is a quite old question but anyway, have you ever tried a terminal emulator? Try Console. It's a free terminal emulator for windows.
and to get to know what a command does type
man <command>
in the terminal.
The book "PhoneGap 2x mobile application development" is quite old. The phonegap/cordova development has changed quite a bit from 3x onwards. The current/latest version is 4x.
Below are the links pertaining to phonegap/cordova 3x which will work for 3x and 4x versions.
hope it helps.
http://thejackalofjavascript.com/phonegap-3-cli-setup-mac-windows/
http://coenraets.org/blog/cordova-phonegap-3-tutorial/
http://teusink.blogspot.in/2013/07/guide-phonegap-3-android-windows.html
http://sdk.revmobmobileadnetwork.com/phonegap_cordova.html
http://docs.phonegap.com/en/3.5.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide
Phonegap Cordova installation Windows
If you install Cygwin you can use unix commands on Windows CMD as you can see on this website https://lifehacker.com/362316/use-unix-commands-in-windows-built-in-command-prompt
Actually, it is possible to run UNIX commands on Windows. Have a look at all of the UNIX commands compiled for Windows in this GitHub repository: https://github.com/George-Ogden/UNIX

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

Running Cygwin commands from batch file

My project is an AndroidNDK project and requires some build commands to run from Cygwin (or a Unix environment). Is there a way to do this using TeamCity?
I tried using the commandline build step and passing in a batch file which first launches cygwin, and then performs the build commands I need. However this does not work, all it does is launch cygwin, but my unix commands do not get executed after this.
How are you launching and running commands from cygwin?
You will have to do bash -c "command you want to run" (assuming bash.exe is on path). Just calling bash and then giving commands will just launch bash.
I used cygwinonce. I tried doing similar you wanted to do.I wanted to start cygwin with default command.
bash --login -i myBashScript.exe
only when we paste myBashScript.exe in bin folder.

Categories

Resources