Linux kernel 3.3 apps on Android - android

There was a recent article that Linux kernel 3.3 has integrated Android as one of the features.
It has also created the possibility of launching Linux applications on Android systems provided the correct drivers are used.
I am currently learning Android app development using Processing language.
I am comfortable with processing language in Windows/Linux operating systems. If I develop a processing application in Linux kernel 3.3 that uses bluetooth communications, is it possible to port it to Android?
If yes, How should I go about doing that?
To summarize my question, Can I port my Linux based processing language apps to android?

Linux binaries have always been able to run on an Android system assuming the proper libraries are available (such as in a chroot). See, for example, Debian & Android Together on G1, the first released Android device.
What is happening more recently is that Android kernel modifications are merged or being prepared for merging into the mainline Linux kernel. This doesn't directly benefit desktop Linux users (who weren't using those additional features anyways) nor Android users (who will continue using Android's kernel), but will hopefully reduce divergence and make ongoing development and maintenance easier.
It also gives rise to the potential of running the Android userspace stack on a mainline Linux kernel, whether on a Android device or not.

You can't do this directly no. You see, Android is based on the Linux Kernel, on top of that are all of the drivers for the specific device and on top of all of that is the Android OS. You need to write code that makes Android OS calls through the sandbox that your app is in.

Related

Difference among Android's emulator command variations

There're several emulator binary variations residing in the Android SDK's /tools folder but I don't find any documentation on their differences (e.g. when to which one).
Android SDK version is 24.4.1, on CentOS.
Normally, you don't need to care about this, a default emulator will be chosen for you (first binary). Each binary represents one of the supported architectures. The last five are the 32-bit emulators.
Android emulator is based on QEMU
When the Android SDK was first made available to the world, Google
used QEMU as the basis for their Android emulator. They copied the
source code to a custom repository in the Android Open Source Project
(AOSP) and made a number of invasive modifications to QEMU.
Specifically, they added emulation of a specific board called goldfish
for the purposes of emulating an Android phone.
Every build of Android targets a specific hardware platform, and the
emulated goldfish platform is no different. A number of specific
emulator features are enabled in both the Android kernel and Android
userspace environment when run in an emulated environment. These
features allow a smooth and complete user experience resembling using
a real Android device, on laptop and desktop workstations.
The Android emulator provides Android application developers with a
convenient development environment and allows developers to develop
and test applications on devices which they do not have physical
access to. With the introduction of the ARMv8-A architecture and
Android support for 64-bit ARM platforms, this need is more important
than ever because it allows developers to begin adapting their
applications to an ARM 64-bit based mobile ecosystem prior to hardware
being available.
You can use the default emulator like here (or add QEMU options, but I never needed it, read this).
You also can force a 32-bit emulator:

Knowledge of Linux for Android

Can someone tell me why Linux knowledge is needed for Android jobs ?
Many of the Android jobs have Linux as a prerequisite.
I can very well develop an Android app from a Windows machine right ?
I would say it might be because they prefer to work on Linux and thus you need at least to know the basic installation of the Android Tooling (SDK, eclipse etc..).
On the other hand Android is based on Linux Kernel and uses some UNIX conventions. A knowledge of how things works is a plus. Processes, commands, packaging are among the ones you should know.
You don't have to be a Linux guru to know this.
But still i believe the most important is the knowledge of Android development which is the same for all platforms.
Android uses DVM (Dalvik Virtual Machine) which is based on linux kernel at the bottom. Hence to have the idea about linux helps in developing android application. You can develop android applications on windows OS as well using android SDK.

Make driver for digital microscope for Android / arm device

I have tablet pc, which uses Android.
It's config:
marvell mohawk rev 0 v51
bogoMIPS: 797.00
Features: swp, half, thumb, fastmult, edsp, java, iwmmxt
cpu implementer: 0x56
cpu arch: 5te
cpu part: 0x840
cpu revision: 0
Hardware: pxa168 edge development platform
My aim is to develop my own driver, which will get stream from usb ( from the microscope ) and then render it in Android app in my tablet pc.
As I understand , I must learn not only arm v5 arch, but need to get arm-gnu C compiler and must know hot to handle byte stream from usb.
I have looked at usblib (OpenUSB) project, but seems to be it's not such clear project for arm arch and will cause a lot of problems.
So, how can I natively get stream from usb of my tablet pc ( armv5/android ), then obtain in in native part ( ndk ) than through JNI send data to Java and render it in my tablet pc.
Is the way I think correct and what troubles I shall get on this way?
Thanaks,
Best Regards
Android runs on a Linux kernel. So what you're after is either a Linux kernel driver for your microscope, or a user mode program to interface with it (some USB devices can be driven entirely from user land). In either case, you'll need to root your device. Use the Android NDK if you need to write a native mode program. If you need to write a kernel module, get the kernel sources for your platform (either from https://android.googlesource.com/kernel/common.git or, if applicable, from a manufacturer-specific repository). Before you embark on writing a driver, check if there isn't already one for Linux; chances that it will work with minor adaptations if at all on Android (what definitely won't work is any Linux GUI application).
Android doesn't currently support 3rd party drivers for USB devices. However, starting with Android 3.1 (Honeycomb), there is a Java API to directly communicate with USB devices. You can write an Android application which detects and communicates directly with your microscope completely in Java. If the processing of the data coming from the microscope requires higher performance, you can write native code (through the NDK/JNI) to do the processing.

Is there some way to develop for Android using an ARM based computer?

I've seen in the Android Developers page that the SDK requires an x86 computer. Is there someway to use an ARM Based linux machine running Ubuntu to develop for Android?
This depends to some degree on what you mean by "to develop for android".
There are a number of scripting tools and frameworks which can be used to create applications on android, without actually compiling any java code. Some of these are intended even for development on the android device itself.
In terms of traditional SDK apps, most of the android toolchain is open source and potentially build-able for any posix-ish platform. The problem is the java jdk - you would need to obtain something to fill that role in the toolchain which would run on your ARM system. Something which compiles another language to dalvik opcodes and thus bypasses the need for the jdk could also be a possibility.
Presumably porting the NDK gcc & binutils along with the android packager is possible, which could make available either the official "native activity" option of more recent android releases, or some custom solution in which the java portion is a pre-generated wrapper and only native code is written for the interesting parts that would have to change during routine app development.
Finally, we aren't far from the point where it would theoretically be possible to emulate an "older" x86 system on a cutting-edge ARM one; potentially the x86 jdk could be run in such a virtual environment, albeit inefficiently.
Since this answer was written, solutions for doing Android Java->Dalvik development on the device itself have become available. As these work at least on ARM-based Android devices, that would qualify as developing for Android on an "ARM based computer". Presumably the same ideas could be applied to an ARM-based netbook or "chromebook" type of system.

Can Linux apps be run in Android?

Android is based on Linux; can native Linux applications be run on Android?
In general, no. Android apps generally run in a sandboxed Java-like virtual machine, so have to be written in Java or some language that compiles to virtual-machine bytecode that use the Android API.
However, the virtual machine does run on top of the underlying Linux OS, and there are ways to call native code. See https://developer.android.com/tools/sdk/ndk/index.html
So, while it is technically possible to run native Linux programs, as there is a Linux kernel running beneath everything, most users would not be able to install such applications or use them. (If you have root access or are building your own firmware, then you can do whatever you want.)
Yes you can. I have installed a complete Debian distribution in a chroot-jail enviroment using debootstrap. (You need a rooted device)
I am now running ssh, apache, mysql, php and even a samba server under android on my htc-desire with no problems.
It is possible to run x applications using a remote x server via ssh. It even runs openoffice.org and firefox.
You can use this: http://code.google.com/p/android-xserver/ to run X-application on localhost but my HTC-desire has a to small screen to be productive :-) But it might be usefull on a Eee Pad Transformer or something like that.
Android does not run X Windows, nor does it have many of the standard GNU libraries. So, since most native linux applications require one or both of these, most will not run.
In addition, even Java programs can be limited, because the version of Java that Android applications are written in is a subset of the standard Java library.
Not directly, no. Android's C runtime library, bionic, is not binary compatible with the GNU libc, which most Linux distributions use.
You can always try to recompile your binaries for Android and pray.
yes you can ;-)
the simplest way is using this ->http://www.androidfanatic.com/community-forums.html?func=view&catid=9&id=2248
The old link is dead it was for a Debian install script There is an app for that in the android market
but you will need root
android only use linux kernel, that means the GNU tool chain like gcc as are not implemented in android, so if you want run a linux app in android, you need recompile it with google's tool chain( NDK ).
You can get an ARM cross compiler that runs on Linux here.
You can also download the Android NDK and compile some command line apps.
I do not have any personal experience with using C++ with either solution, but I have compiled a few simple things with both. It is my understanding that the NDK is not a full C++ compiler as there have been complaints that it will not compile some common C++ code.
Note that since I am a new user, I cannot post the NDK link... :/
I think this article can provide a solution : Linux Today - Compile, Install and Run Linux apps on Android
Hope it helps.
yes i have done that on several rooted machines
i set a debian linux on a sdcard by dd.
i copy this script http://jeanmichel.gens.free.fr/etc/install on /system/bin
i have not yet succeed to run a Xserver but i can use xwindows binaries through the android Xserver application
i can run update my debian with apt-get upgrade , run an apache server with PHP , run a ssh server
and all binaries on a terminal including user management
i have also a problem with semaphores handling
please contact me if you have any trouble
Yes they can if they're compiled under an arm linux first or using a cross compiler. Debian arm versatile works, there's also arm-eabi for compiling under x86 linux to arm linux.
Yes, they can. If you do not have a rooted phone/tablet, then you could download c4droid here to compile your apps. Then, you could download Kevin Boone's KBOX here to run the program.
Hell, of course yes, with several limitations.
Android is a kinda special Linux distribution, with no usual suff like X11, and you can't install Apache2 with apt-get. But if you have ARM cross-compiler, you can copy your ELF files to the device, and run it from a terminal app or if you have installed some SSHD app, you can even use SSH from your desktop/notebook to access the Android device.
To copy and launch a native Linux executable, you have not root your device. That's the point, where I am, I've compiled my own tiny webserver to Android (and also for webOS), it runs, hallelujah.
There comes the issues, which I can't answer:
My tiny webserver use only stdlib and pthreads. I have no idea how to use the (native Linux) libraries comes with Android, there are useful ones, altough, I can live without them.
Now I can launch my app from a terminal app by hand. But I don't know, what's the best way of deploying such native apps to Android. I think I should be write a small Android app, which launches the server and not letting automatically stopped by the system (say, as like music players never killed). Also, if its a service, it should somehow started on boot. I'm not familiar with Android.
Short answer, no.
Long answer, you can run Linux application if you install some software.
To avoid rooting your device, you can try the GnuRoot and XSDL combo to get a minimal chrooted environment, (Actually, it use proot to enable a rootless chrooted jail), or get the Debian Noroot application, which combine the former two application in a single virtual machine environment.
Both can be fetch from Google Play.
However, there is a few drawbacks: first, the X11 Server bundled by XSDL and DNR is a compatibility layer wrapped around a Android port of SDL library and SurfaceFlinger.
This means, hardware accelerated OpenGL graphics are not avaliable, and even the sound support requires some hacks. So, the author choose a simple Desktop Environment: XFCE4 suitable to low memmory and no 3D support.
The second problem is the incompatibility from the DNR Virtual Machine of direct hardware acess, since it requires real root privileges. So you can't burn DVD, print using USB cables,... even the author's projects may promise a workaround in a future.
Finally, this solution enables to install user-space programs like LibreOffice, Gimp, Samba,... not kernel-space modules.
Even with this limitations, the DNR is a very powerfull program.
You can install chrooted linux distribution alongside android bacause android is based on linux kernel. If your phone is not rooted, you may use fakeroot (easiest way is to use Debinan nonroot app) even with GUI (with android X-server app or via VNC). If you have a rooted phone, you can install almost fully functional distribution.
I think the best performance and the least limitations you can achieve with Gentoo because all software compiles to your native arm architecture and it is the most flexible, but not the easiest. You may be interested in this post about installing Gentoo on android.
It depends on what you mean by "Linux applications", and what you hope to achieve.
First, if you mean, can you copy an x86-64 Linux binary executable to an Android device running on an ARMv7 processor, and run it... well no, that won't work at all, for several reasons.
If you mean, can you run Linux programs within a Linux emulator running within Android, sure... with limitations. Have a look at "Termux". With that, you can run many command-line applications. With a VNC server running in Termux, you can run some Linux X GUI applications, and use them in a VNC client (See the Termux Wiki). There is also "Termux:GUI" --- I've never tried it.
If you mean, is it possible to compile applications meant to run under Linux, so that they can run as native Android apps, well, that depends.
Up to Android 4, you could cross-compile a C "Hello World" for ARMv7 under Linux, adb push it over to an Android phone, and run it in an Android terminal emulator. I have done it. But the security model of more recent Android systems makes that much trickier: there is no way to give such a file Linux executable permissions. (chmod 777 does not function.) On a rooted device, such things are still possible.
I suspect that it is possible to install native ARMv7 binaries (even without the NDK --- say, just a "Hello World", which doesn't require all that), along with an Android app installation, so that it is executed from the app. It's only a matter of permissions. I haven't yet figured out how.
But a "Hello World" isn't really a Linux application. A Linux application would make use of the Linux system and libraries. And even on a rooted device, what remains of Linux in Android is terribly limited and altered. You would have to build up the necessary software infrastructure to run a more elaborate application. And that might be an impractical task.
But if you're going to do that... wouldn't it be better to just root the device, and install Linux on it? That can be done, too. Sometimes.
these are all total lies above
Android x86 pie uses linux kernel 4.19 with most PC kernel modules DISABLED (you have to rebuild the kernel yourself for PC hardware - for VM maybe not)
Android installs unix (GNU+freebsd+ubuntu parts google threw together) in, was it, /system/bins
there seems to be some heavy lying going on by ubuntu, rh even android about whether Android has a linux OS
it most certainly does: and, the Java is Sun/Oracle java, and it is intalled as a linux version, and requires a linux OS to load it
You cannot build an app for phones, say it is "for Android" that doesn't sandbox and breaks Android: it's against policy and they will come after you and remove your app off the store for good reasons. HOWEVER: you can do it at home on your personal android if you can afford to be an unpaid developer :)

Categories

Resources