I'm using Terminal-IDE as my development environment. (Google code site here.)
I'm running Terminal-IDE v 2.02 - the very latest. My Android versions are:
Android 4.0.3
Software version 2.14.531.3 71ORD
(the rest aren't likely pertinent, but more on request)
I'm in a suitable development directory with a simple enough c source code file ready and run 'make'.
I have never yet gotten any compilation to work successfully. Most likely, there's a version mis-match with regard to what executable is available versus what the software is looking for.
Here's the command and error message:
terminal-gcc -c -Wall -I/data/data/com.spartacusrex.spartacuside/files/local/include tester.c -o tester.o
/data/data/com.spartacusrex.spartacuside/files/system/bin/terminal-gcc[43]: arm-eabi-gcc: not found
make: *** [tester.o] Error 127
Snafu, of course. I'm not at all sure how to find out what the right compiler file name(s) should be because, on this non-rooted phone, I don't have permissions to hunt through the PATH and find the actual executables.
It may also be that PATH is set wrong. All input appreciated.
...I'm not sure what's supposed to happen, but I found in the Terminal-IDE directory tree the file:
$IDESYSTEM/android-gcc-4.4.0.tar.gz
I also found that terminal-gcc is a bash script. Looking inside it seemed to say that a gcc tree should exist in "$HOME", which is the installation directory. So, I unzipped, then un-tarred the file identified above and put the resulting directory tree as a top-level subdirectory.
Well well, what do you know? Success.
I went a little further and created soft links to the actual compiler in ~/bin for both gcc and just cc, and suddenly all my previously created "Makefile" scripts used in other projects I wanted to move over started working perfectly.
Apparently, even though I thought I'd done it right, I overlooked running this script:
./system/bin/install_gcc
It extracts the tar, like I did, but does not create the links you may need.
Hey, if you're glad I got here before you, give it a thumbs up!
A credit goes to #Richard T for his enthusiasm regarding Terminal IDE. The answer is intended to enumerate the steps needed for running a C code.
To run a C code
Run Terminal IDE and extract the gcc package by executing
install_gcc
Create a directory for your projects within the Terminal IDE directory tree. Then in the directory create a source .c file with some code (filename.c here). Compile it
terminal-gcc -c filename.c
Create the executable file
terminal-gcc filename.o -o filename.out
Run the output file
./filename.out
If you'd like to use the PC (laptop) keyboard you can telnet Terminal IDE.
To Telnet Terminal IDE
From Terminal IDE start the telnetd deamon by executing
telnetd
Connect the Android device to the PC (laptop) and type
adb forward tcp:[port] tcp:8080
telnet 127.0.0.1 [port]
P.S. Telnet's default port is 23.
Related
I am trying to build a framework.jar from android-x86 aosp but 'mm' in /frameworks/base return "No such file or directory". And also I tried "make framework" but after that framework.jar size in out 300 bytes. I tried "make modules" to get framework module name but list so long. May be somebody know what module name for build complete framework.jar ?
Update: I don't know why mm and mmm don't work for me, but I understand thats "make framework" work correctly, after android 5.0 java classes compiling in ART .oat and .odex files. But I try to reverse emulator framework.jar that have framework.jar fro dalvik with .dex files inside. And it confused me when I compared the builded and emulator file.
Firstly, you should have these in your ~/.bashrc when, and do a full build/flash. Otherwise making and building just parts of framework will cause the device to not boot. These will cause the first boot to be a tad slower since the pre-optimizations are not done at build time.
export WITH_DEXPREOPT=false
export DISABLE_DEXPREOPT=true
export DEX_PREOPT_DEFAULT=nostripping
Next build, you can run just
source build/setupenv.sh
lunch XXXXX-userdebug
make framework
And to update on device
adb root
adb remount
adb sync
adb reboot
Try running below command from AOSP main directory:
mmm frameworks/base/
First setup environment by this command :
source build/setupenv.sh
Second lunch your target
lunch your-target
Third use this command to build framework.jar
mmm framework/base
if you have any problem or error , clean the source directory first and then run the third command
make clean
I need to edit run.sh file in eclipse in windows. I'm following instructions in here, and I've installed the Android app completely and it's OK on my Xperia, however when it comes to building the host client part in the fourth line I don't know what run.sh does neither I know how to edit it,by the way, I guess it's a Linux file. And I have to say that I haven't installed CyanogenMod software as it is not Xperia p compatible according to it's website. The code in run.sh file in se.pki.client package, which I downloaded and imported previously, is as following.Althoug I've changed the code in the second line(giving it the path where my jdk is stored) while there's still an error in the first line saying the word "sh" is not correctly spelled and another error in the third line to
#!/bin/sh
JAVA_HOME=C:\ProgramFiles\java\jdk1.7.0\
$JAVA_HOME/bin/java -Dsun.security.smartcardio.library=/usr/local/lib/libpcsclite.so -cp bin/ org.nick.sepkiclient.Main $*
.sh files are the linux equivalent to a batch file. From the code you posted it just runs the java command (giving it a bunch of command line inputs) you should be able to run the same command in the windows terminal by just replacing the paths to windows paths. If there is more to the script than the 3 lines, you're going to needed to try and convert each line to a valid windows command (depending on the complexity of the script, this may not be possible.)
Your other option is to install software like Cygwin which adds a POSIX compliment shell (along with many other linux-ish modifications). This should allow you to run .sh files 'natively' in windows (it will require some fiddling with the script to provide the correct paths). Be sure you read about cigwin before you install it, it changes quite a lot about your system that you might not be comfortable with.
Each option has its drawbacks, and both require a little knowledge of shell scripting. Might just be easier to run Linux for what your doing (it behaves itself reasonably well in a VM).
Make sure you have it set as a unix file.
Window> Preferences>General>Workspace
Select line delimiter Other then Unix and test file encoding as UTF-8
As a last resort run dos2unix on the file from the shell.
I followed the steps in the forum (http://www.schaeuffelhut.de/wordpress/?p=237&cpage=1#comment-384) to get the linux kernel source and and cross compile my module. The kernel version of the google nexus one is exactly the same as in the forum. I initially tested with my test module hello-1.ko which got installed on the android device successfully. But when I am installing my module ec.ko on the android device using insmod, I get the following error.
apurva#apurva-Inspiron-1464:~/$ adb shell
$ cd sdcard/data/ec
$ ls
ec.ko
$ su
# insmod ec.ko
insmod: init_module 'ec.ko' failed (No such file or directory)
#
It is clear that the file ec.ko is present. But I am not sure why it is not picking the file. I did the same thing for hello-1.ko and it gets insmod pretty fine. There is no permission issue, and ec.ko gets the same permission as was obtained by hello-1.ko.
Now this bring me to the question, Are there certain limitations of a kernel module in an android device because this module gets insmod in Ubuntu. Next action for me is to go for a hit and trial method and check what lines in ec.c is causing the problem. Meanwhile if you some suggestion, please let me know.
You can check the dmesg log to see something can help you.I have also encountered the same problem.Following is how I solved this problem.
I installed my module on the android device by using insmod command,but I got the same error message like you.I checked the dmesg at that time,and I got this:Unknown symbol "XXX"(I have forgotten the function name.).I used the command —— cat /proc/kallsyms |grep "XXX" to find this symbol,but I found nothing.The reason for this problem is the function have been deprecated in AndroidM.Finally,I fixed this problem by annotating the function.
I have been trying to port Node.js on Android phone
by following the link below
http://www.xydo.com/toolbar/20311835-node_js_on_android
I created the node.tar on QEMU environment and sent it to the ubuntu machine ?
I have put all .so files in system/lib and node bin file in system/bin .
When i try to run it it gives "Node not Found " even though it is present .
NOTE : I have manually pushed the files since tar command does not work on android .
I am using a rooted device .
Is there any way to create the binary file in android directly without the ARM environment ???
Am i missing something ?Thanks for the help .
Thanks for the response .
I have installed debian on Android using your suggested link:
http://lanrat.com/android/debian
After that, when I run the following commands on chroot to be able to make and install Node js, (ref:http://howtonode.org/f1932c1c56d3a50fe0c21998362d80f405229b5a/arm-chroot-fun)
$git clone http://github.com/creationix/nvm.git
$. nvm/nvm.sh
$export JOBS=1
$nvm install v0.4.11
I get the following error:
/.nvm/src/node-v0.4.11/deps/v8/src/arm/macro-assembler-arm.cc:61:3: error: #error "For thumb inter-working we require an architecture which supports blx"
scons: *** [obj/release/arm/macro-assembler-arm.o] Error 1
scons: building terminated because of errors.
Waf: Leaving directory `/.nvm/src/node-v0.4.11/build'
Build failed: -> task failed (err #2):
{task: libv8.a SConstruct -> libv8.a}
Alternately, if I try the following:
$ mkdir tmp
$ cd tmp
$ wget http://nodejs.org/dist/node-v0.4.11.tar.gz
$ tar -xvzf node-v0.4.11.tar.gz
Added '-march=armv5t' to 'CCFLAGS',in node-v0.4.11/deps/v8/SConstruct and the
$ cd node-v0.4.11
$ ./configure
$ make
$ make install
the installation runs without errors, node --version reports v0.4.11 and when I try to run any node commands, I get pure virtual method called terminate called without an active exception Aborted
can you please let me know what i am doing wrong here?
You definitely have tar on your phone and everything else that comes with busybox! http://en.wikipedia.org/wiki/BusyBox Also look at this it will improve your Droid hacking time 10 fold https://github.com/jackpal/Android-Terminal-Emulator/wiki/Frequently-Asked-Questionsand consider acquiring http://www.magicandroidapps.com/wiki//index.php?title=Main_Page and https://market.android.com/details?id=org.pocketworkstation.pckeyboard Your going to wonder how you where doing it before you got these. The tutorial you where following was a little shaky so I included the resources I used to get ubuntu and nodejs running on my Android. It took me a while but it was a lot easier after a little research on how exactly debootstrap and qemu worked, you have to get a little linuxy but once its running you will be amazed at all the options you have. http://lanrat.com/android/debian http://howtonode.org/f1932c1c56d3a50fe0c21998362d80f405229b5a/arm-chroot-fun What I ended up doing was building a cross compilation tool kit using deb boot strap and qemu and compiling everything on my desktop then moving the image over to my Android. Lastly I included my arm ubuntu Image. You may have to tweak the bash script a bit but other then that the image is universal and even runs on an IPhone. If you have any trouble digesting all this or getting the image working feel free to ask. I want to see node on as many phones as possible! www.castedspell.com/ubuntu4droid.tar.gz The image is 3 gigs uncompressed but really only 600 mb and you can use any partition re-size tool to shrink it down.
There is an Android port of NodeJS with source you can get up and running with.
Can anyone tell me how to run ndk-gdb from within emacs using gdb-mode? I'm currently running it in a shell buffer. What I'd love to have is a way to automatically sync a source file buffer with the current pc in gdb when I break or step. Anything more, like setting breaks from source, buffers that show gdb locals etc., and key shortcuts for gdb commands would be gravy.
Background: I'm developing in GNU Emacs 23.1.90.1 (i386-apple-darwin10.5.0, NS apple-appkit-1038.35) of 2010-12-15 on OSX 10.6.6 with android-mode, using android-ndk-r5b and mixed java/c/c++ code for an android target.
Android-mode and shell (running ndk-gdb) within emacs allow me to see just about everything I need, but my setup would be more convenient if I could get a source buffer to sync with the debugger, or get the equivalent of what is described in EmacsWiki here.
FYI, I'm currently using eclipse for java side debugging and development, but finding it unstable and difficult to set up for native work, despite the availability of sequoyah, and besides, eclipse is no emacs.
[Appended]
Running M-x gdb with ndk-gdb as the gdb command (see below) results in a buffer called gud with a modeline saying "(Debugger:run [initializing...])". The buffer does not accept gdb commands, nor does it accept emacs gdb commands - (M-s, M-n etc result in <>
Output:
Current directory is /Users/jpschelter/
Android NDK installation path: /Developer/android-ndk-r5b
Using specific adb command: /Developer/android-sdk-mac_x86/platform-tools/adb
...
... ...
...
(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0xafd0e21c in nanosleep () from /Developer/Projects/ECS/DIGG/Projects/droid/obj/local/armeabi/libc.so
(gdb) Undefined command: "1-inferior-tty-set". Try "help".
(gdb) Undefined command: "2-gdb-set". Try "help".
(gdb) Undefined command: "3-gdb-set". Try "help".
(gdb) Undefined command: "4-file-list-exec-source-files". Try "help".
(gdb) Undefined command: "5-file-list-exec-source-file". Try "help".
(gdb) Undefined command: "6-gdb-show". Try "help".
(gdb) Undefined command: "7-stack-info-frame". Try "help".
(gdb) Undefined command: "8-thread-info". Try "help".
(gdb) Undefined command: "9-break-list". Try "help".
Buffers called *threads of*, *input/output of* and *breakpoints of* are also created, but are empty.
Browsing through the gdb-mi.el source of my emacs, and comparing to the gdb-debug-log output, it looks like gdb-mi is trying to send these parameters to a gdb executable, but gdb-server is not responding to the commands as expected?
Note that running M-x gud-gdb with the command-line for ndk-gdb seems to result in the equivalent of running ndk-gdb within a shell, so the issue seems to be within the configuration of gdb-mode in emacs.
I had the exact same problem when running gdb under emacs: the *gud* window was not responding to commands. However, ndk-gdb was working well in a shell. To make it work under the emacs gud UI, I had to modify the ndk-gdb script a bit.
On call to GDB (last line), do this:
$GDBCLIENT --annotate=3 -x `native_path $GDBSETUP`
The --annotate=3 option is mandatory for emacs gud interface, it cannot work without it (that's why *gud* was not responding).
But you're halfway. Now it will work, but only if you invoke ndk-gdb while in a buffer from a file at the root of the project (like AndroidManifest.xml). Since this is very unlikely most of the time because you are a C/C++ programmer and the sources you're working on are under the jni directory or deeper, you need to do a little more. The ndk-gdb script is a bit buggy and it will happily confuse you on this one (and gdb itself won't help much either).
Search the script for "PROJECT=$OPTION_PROJECT". You will be in a long if...else...fi clause which is in charge of finding the root of the project (if it has not been given with the --project option, though doing so WILL NOT resolve the issue I talk about, see below). After the fi, add this line:
cd $PROJECT
For some obscure reason, the script DOES NOT cd to the project root directory. This leads to very wrong behaviour when dealing with the gdb.setup file where the script assumes to be at project root. Adding this line will fix it.
Make sure you call ndk-gdb within emacs with the usual command:
(gdb "ndk-gdb ...")
Do not use gud-gdb (oddly, this is old emacs way of using gdb and has nothing to do with the nice UI you're searching for). Replace ... with your arguments, (concat ...) or anything you wish. I strongly recommend to use the --project option anyway. If you don't and you are in a buffer for a file which is out of the project, the script won't find the root. Worse, if you're in a file in another Android project, it will find the root of that project instead (maybe even copying gdb.setup and stuffs into it before failing the gdb session). So give that damn --project option. If you're using emacs desktop command set, do this:
(gdb (concat "ndk-gdb --project=" desktop-dirname ...))
(assuming your .emacs.desktop is at the root of the project, of course).
Now you can finally debug with gud UI, setting breakpoints at source level.
Note that I use emacs 23.3.1 (gdb-ui.el), so there is no need to have 24 for this to work.
Have you tried this?
Add android-sdk-mac_x86/platform-tools and android-ndk-r5b to PATH environment. After that, start gdb mode with ndk-gdb script.
M-x gdb
Run gdb (like this): ndk-gdb --verbose --start --project=your_NDK_project_dir