Golang for Android on Windows? - android

I haven't read anything explicitly stating that you can't use Windows but everything that does walk you through what to do seems to involve running a .sh file. Has anybody had any luck compiling any kind of Go for Android, whether it be a library or a full native activity?

No, the all process is tied to Linux (FROM ubuntu:12.04 in the Dockerfile).
That means you would need to have on Windows a Docker-compliant environment (like a boot2docker) in order to launch the
docker run -v $GOPATH/src:/src mobile /bin/bash -c 'cd /src/your/project && ./make.bash'

Related

Running elf executable on Android

I was wondering if the only way to run an executable in android is by installing an apk. Would it be possible to run an elf executable? Just as done on linux.
Just drop and run it might be a problem due to restrictions that android uses. Note that those restrictions are updated every Android version.
If you target your executable to run on a rooted device, you can write an app that dumps the executable in a way that bypasses the restrictions and runs it.
If you target you executable to run on a custom ROM or Recovery, you can place the executable in a way that pass the restrictions and run it (without the need of a wrapper app).
if the executable is built for the target architecture, then
If the executable is statically linked: Yes
If the executable is built with Android toolchain/NDK: Yes
If you have the libraries against which the executable is linked: Yes
fi
If you have USB debugging enabled, just use adb push to copy the executable to device, not to a location mounted with noexec, and go to the shell with adb shell, and execute it. You might need to chmod it before executing.

How to invoke "./configure; make; make install" on Android adb

I have a program that I would like to install on an android phone (x86). The program can be installed on a Linux PC. The procedure of installing the program on the PC is:
$./configure
$make
$make install
Now I would like to do the above through android ADB so I can install it on the phone. What are the utilities needed? (I cannot find "make" in busybox http://www.busybox.net/live_bbox/live_bbox.html)
Building your program directly on the phone probably isn't going to be practical. The number of dependencies that make will wind up invoking during the build process will be huge, and either not exist or not work well on the device itself.
It would be better to look at cross-compiling, where you use a different system to build a binary that is suitable for your device.
It wouldn't be possible to provide more specific info without more detail, but be warned: you're probably in for a big project.
Maybe start here? http://forum.xda-developers.com/showthread.php?t=2723240

How to write dead simple native SERVER program (not app) for Android devices?

First of all, I believe, it's not a duplicate question. I don't want to write a native app with NDK, I just want to use Android device as a cheap Linux server. Server, in this context, means a program, which has no UI. Also, the server is written in bare C++, but uses no libraries at all, so that's why should that question differ from others.
The story
We've written a small server for Linux, it has a webserver interface, so you connect to it with a vanilla browser, and you can play with it. We've compiled it to Linux/x86, Linux/ARM (GuruPlug), Linux/PPC (some kind of NAS), and Mac OS X Darwin platforms.
The Linux/ARM version also runs well on my Palm Pré smartphone. I've just copied the executable onto my phone (in webOS scene, there's no such thing like jailbreak, there's an official "developer mode", which if you activate by typing a secret key combination, you can log in to your phone with ssh or use local ssh app). So, our small server program (daemon, may say) is running on even the smallest Linux devices. (It's funny, when connect with your giga-powered desktop machine's browser to a smartphone server.)
The server program is designed to run on even the smallest Linux (as I said, it runs on NAS, router, smartphone), it requires only STDLIB and PTHREADS.
The question
What't the straight way to get that simple server program run on an Android device?
We have no Android device yet. But I assume, any ARM-based one will do. The server's memory footprint is so small, that it will be no problem.
I assume, the device must be rooted to copy executable to it and run.
I don't want to install a whole new Linux on the device. It should keep running Android, while our server works in the background. The Linux distribution which enough for Dalvik, is enough for our server, I'm pretty sure.
The server should use no external things (USB, touchscreen, audio, camera, mic - thanks, not) only a port for webserver (e.g. 8080), which is not allocated by Android.
I have ARM GCC toolchain, the installation of it is not the part of the question (except if there're tricks).
The installation of the program should be manual (scp, whatever). Also, I don't want to make a package or any automated deployment.
The problem of the launching of the server program is another question, we'd ignore now.
So, I want just do the same thing with an Android device (phone, tablet), just as I did on my webOS device: copy the server program and run on it. Computers are for that, running programs, aren't they? ;)
I have not really tried it, but it should be possible to use the ARM GCC compiler you have, or the one provided by the Android NDK to compile native application, the same as you would use it on your desktop.
If your application is small (not too many files), you can manage the compilation by hand (or in a simple Makefile). The following commands are from the LuaJIT compilation guide for Android:
/tmp$ cat test.c
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}
/tmp$ NDK=/opt/ndk
/tmp$ NDKABI=8
/tmp$ NDKVER=$NDK/toolchains/arm-linux-androideabi-4.4.3
/tmp$ NDKP=$NDKVER/prebuilt/darwin-x86/bin/arm-linux-androideabi-
/tmp$ NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
/tmp$ ${NDKP}gcc $NDKF -o test test.c
/tmp$ file test
test: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
Obviously, use linux-x86 instead of darwin-x86 if you are on Linux (not Mac OS X, also not sure about Windows), and change the path to NDK to where you installed it.
Now you have to move the compiled binary somewhere to your Android device, and run adb shell to see if it works:
/tmp$ ADB=/opt/sdk/platform-tools/adb
/tmp$ $ADB push test /data/
332 KB/s (3343 bytes in 0.009s)
/tmp$ $ADB shell
# /data/test
Hello world!
You definitely need a rooted android device.
I recommend that you install busybox to get a bunch of nice command line tools such as wget, tar, gzip and many more.
You can get shell access to your device by using adb shell and then su to get root access. You can either use adb push or wget to put your server on the device.
The /system partition is mounted as read only and depending on the manufacturer there are a lot of protections that restrict you from writing there so you should copy your server somewhere on the /data partition (e.g. mkdir /data/myserver). After this, everything should be pretty straight forward.
Perhaps the question is more a sysadmin issue (how to install your executable on your Android device) than a developer issue (how to cross compile a C program for Android)?
I have a chroot partition with my android galaxy phone. It is arm with floating point processor, so all kinds of compilers work. Warning to you: the busybox/android distro utils don't run as GNU software. Their tar have problem unpacking the first thing I tried. POSIX tar not supported. Their zip have problem with some field 1 or 8. Their mount works like somthing from space. Their partition itself that you will want to have software put on does not support sym link. After a few weeks working on the chroot partition, I start to feel that the whole android is just a new underlying BIOS, with lots of firmware.

unable to run node.js on Android phone?

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.

What do you use the Android Terminal Emulator for?

Why is there a terminal emulator in the Android App Market?
So you can get direct access to the commandline?
Android is based on Linux, so it's essentially the Linux commandline you'd be accessing here
If you don't know the Linux commandline:
http://linuxcommand.org/learning_the_shell.php
Please note that it'll be a somewhat limited environment - you might need to root your phone to get access to everything, also some commands won't be available, you probably want to install something like Busybox to get a more featureful environment.
Cheers,
Victor
As above - it's for shell access, once you have root.
I've mainly just used it for browsing the file structure to get a better idea of where everything sits.
We use terminal emulator on Android for executing Linux core shells or other shells and program like that. It is a very useful app for Android developers.

Categories

Resources