Linking & Using Non-NDK Android Platform Libraries - C++ or Other Android Development Languages

Hey Guys,
I'm working on a global audio tuning system for Android similar to Viper4Android and JamesDSP, but allowing the User to program and create their own audio filters on the fly. In order to do so I need to link against libLLVM.so which is one of the Android Platform Libraries which doesn't seem to be exposed via the NDK (https://android.googlesource.com/platform/external/llvm/).
My assumption is that I will need to build that library from AOSP Source independent of my project and then link against my locally built copy. Once compilation of my project is complete I don't need to distribute my locally built libLLVM.so file since I can leverage the one existing on the actual device.
I just wanted to see if anyone has any experience doing this, or if I'm going off the deep end.
Thanks!

Related

C++ Compiler for Android?

After googling this topic and finding nothing, I figured XDA was the place to go. I am looking for a way to get a C++ compiler working on my phone (mytouch slide) or android in general.
Thanks in advance
Que? Like a C++ compiler to compile for android? Why would u want this C++ don't run native on Android it must be called from java so it would be pointless.
There is an sdl port around that required zero knowledge of.java but I believe it still has to compile the java each time. If not it could be possible...
Sent from my Nexus One
I don't want to run the programs on my phone, just compile
Compile for what?
What is the Android NDK?
The Android NDK is a toolset that lets you embed components that make use of native code in your Android applications.
Android applications run in the Dalvik virtual machine. The NDK allows you to implement parts of your applications using native-code languages such as C and C++. This can provide benefits to certain classes of applications, in the form of reuse of existing code and in some cases increased speed.
The NDK provides:
* A set of tools and build files used to generate native code libraries from C and C++ sources
* A way to embed the corresponding native libraries into an application package file (.apk) that can be deployed on Android devices
* A set of native system headers and libraries that will be supported in all future versions of the Android platform, starting from Android 1.5
* Documentation, samples, and tutorials
The latest release of the NDK supports these ARM instruction sets:
* ARMv5TE (including Thumb-1 instructions)
* ARMv7-A (including Thumb-2 and VFPv3-D16 instructions, with optional support for NEON/VFPv3-D32 instructions)
Future releases of the NDK will also support:
* x86 instructions (see CPU-ARCH-ABIS.TXT for more information)
ARMv5TE machine code will run on all ARM-based Android devices. ARMv7-A will run only on devices such as the Verizon Droid or Google Nexus One that have a compatible CPU. The main difference between the two instruction sets is that ARMv7-A supports hardware FPU, Thumb-2, and NEON instructions. You can target either or both of the instruction sets — ARMv5TE is the default, but switching to ARMv7-A is as easy as adding a single line to the application's Application.mk file, without needing to change anything else in the file. You can also build for both architectures at the same time and have everything stored in the final .apk. For complete information is provided in the CPU-ARCH-ABIS.TXT in the NDK package.
The NDK provides stable headers for libc (the C library), libm (the Math library), OpenGL ES (3D graphics library), the JNI interface, and other libraries, as listed in the section below.
The NDK will not benefit most applications. As a developer, you will need to balance its benefits against its drawbacks; notably, using native code does not result in an automatic performance increase, but does always increase application complexity. Typical good candidates for the NDK are self-contained, CPU-intensive operations that don't allocate much memory, such as signal processing, physics simulation, and so on. Simply re-coding a method to run in C usually does not result in a large performance increase. The NDK can, however, can be an effective way to reuse a large corpus of existing C/C++ code.
Please note that the NDK does not enable you to develop native-only applications. Android's primary runtime remains the Dalvik virtual machine.
The ndk allows u to use c++ c/c++ code in Android. That code must be called from java tho.
Sent from my Nexus One
I don't think you guys are understanding his question... He's not looking to write apps for Android... he's writing stuff in C++ (presumably for desktop or maybe other embedded applications, I dunno) and just wants to be able to compile that code on his Android device...
Now as far as an answer to that question, they did kinda cover it... Since pretty much everything in Android runs in Java, I believe it would be pretty difficult to write a C++ compiler that could run on Android.
To install an compiler in your Android device, google around for how to install Debian in it. Don't be afraid, you install it in parallel of Android, you will need a command or terminal window as well (available in the marketplace).
Debian comes with everything you need to compile in your device.
I hope I was useful.
Cheers
Thank you abrigham for clearing that up for me. You are exactly correct.
Ernestus, that seems like it would cause more problems then it would be worth
hmm.. i was googling for this as well.. thought it'll be useful to have this around.
JDV28 said:
Thank you abrigham for clearing that up for me. You are exactly correct.
Ernestus, that seems like it would cause more problems then it would be worth
Click to expand...
Click to collapse
Next best option then is to cross-compile to Android/ARM from another platform. The arm-eabi toolchain provided by Google's NDK is one option as others have already mentioned.
Codesourcery ARM toolchain is another, for Linux i686 theres link to the downloadable archive see this post (search for 'wget THISLINK' text on that page).
- jc
If your looking to corss compile for android, check this link out.
http://teslacoilsw.com/dropbear
Installing debian isn't too bad, and would give you the most flexibility for compiling on the phone.
You could also ssh into another computer using connectbot or some other terminal and code/compile remotely.
Another way to do remote compiles is continuous integration. Edit/upload the file to your repository, and using a server such as Jenkins, run the compile and view the results through the browser or an app such as Hudson2Go. Jenkins will also auto-compile on edits and can send you a text if the build fails. Jenkins is very easy to setup.
Try finding an online c++ compiler or you could connect to a windows or linux machine/server to upload andcompile your c++ files.
JDV28 said:
After googling this topic and finding nothing, I figured XDA was the place to go. I am looking for a way to get a C++ compiler working on my phone (mytouch slide) or android in general.
Thanks in advance
Click to expand...
Click to collapse
Use "c4droid" this is a paid app.. anywy if you like search on the market.
Another alternitiv is out there now. Not sure how good it works.
C / C++ Compiler
im looking for compiler too i found i market a4droid compiler but it costs... and i couldnt find enywhere free apk
Easiest thing to do would be a chroot Linux environment from an existing distribution, like Ubuntu. Then compilers for nearly any language you can think of are an "apt-get install" away.
If you're running CyanogenMod 7, you have a large SD card, and you don't mind repartitioning the SD card and shaving off 2 GB or 4 GB for Linux, then I'll be posting a howto in the next day or two. I have Ubuntu 11.10 Oneiric Ocelot running out of /sd-ext cleanly, using only files from official sources (<32 MB file from cdimage.ubuntu.com and everything else via apt/dpkg with signature verification) rather than from rapidshare-like sites.
Or about a year ago there were instructions posted for unzipping a ~2 GB image containing an older version of Ubuntu downloaded from a filesharing site. You could do that if you have an immediate need.
you can download from my blog
http://dateno1.egloos.com/855501
it from https://market.android.com/details?id=com.n0n3m4.gcc4droid&feature=more_from_developer
it has some library problem but work well (i already compile few binary for my phone )
I think c4droid maches perfectly what you were looking for. I'm using it to work on my projects "on the road" and so far it works pretty well.
A little tricky to set up, since you need "gcc plugin for c4droid" but to choose g++ compiler, and builds are saved at "data/data/com.n0n2m3.c4droid/files/temp" or something like that...
There's another option, but you still have to pay: DroidEdit Pro. Perhaps better editor (didn't test it though) but without it's own compiler, you have to set up an external compiler from sftp server.

[Q] AOSP and Android SDK

How does the AOSP and the Android SDK relate?
If I repo the AOSP do I by default now have the SDK?
Do I have to download it separately?
Or can I/Should I compile it from the AOSP?
I ask because after following the instructions up until: source.android.com/source/building.html. I successfully compiled full-eng and ran the emulator and everything works just fine. It also seems like adb is installed which from what I understand is a part of the SDK. I can't seem to find an answer to this.
So I am going to do my best at answering my own questions and posting for the benefit of anyone else who may be confused; if any of the statements I make are wrong feel free to correct me. This is just from my experience. There seems to be little information regarding how the two relate excepting the build/core/build-system.html, and sdk/docs/howto_build_SDK.txt included with AOSP and airtower.wordpress.com/2010/07/25/building-the-android-sdk/ and of course, trial and error.
NB: jindroid.com/2009/06/08/howto-build-sdk-from-android-source-code/ points to documentation that has since moved to the above location it seems. At least it wasn't there for me as of the most recent repo sync against master.
rpowell8 said:
How does the AOSP and the Android SDK relate?
Click to expand...
Click to collapse
The android SDK is a subset of the ADT (Android Developer Toolkit). The SDK as you download it today is basically just a few binarys for getting the actual content SDK.
I think the best way to describe the SDK is that it is divided into to parts tools, and libraries. The tools are for managing the sdk (tools/android) and misc tools to build apk's, align them, emulate an api etc, and then there are the tools in platform-tools which allow you to perform operations on your device (adb fastboot etc). The "libraries" are a set of API's , system images (file for running an android virtual device (emulator)), and documentation for each release of Android. These seem to reside under platform/
You can either download the above components from the command line, or from eclipse. Eclipse is actually included in the ADT as well with the plugin for android apps preloaded. If you don't have the plugin, you can get it vie Help/Install New Software. This launches what seems to be a front end for the android SDK Manager which allows you to graphically choose which platforms you want to support and emulate.
Now, how does the SDK (the tools and libraries) relate to the AOSP as you repo init/sync from the master repository? It seems you can't build apps from the code downloaded from the AOSP git repo (I'm not sure about this but doesn't seem like it). Instead, what you do, is you use the AOSP to build the SDK (NB: when you use the SDK Manager as mentioned above, you are getting prebuild SDKs, if you want to build the SDK yourself you use the AOSP code) as described in the above mentioned howto. Once the build for the Android SDK is complete it is located in out/host/linux-x86/sdk or similar directory. You can actually point the eclipse plugin to this directory as the location for the SDK...but I recommend using the .zip file that is in that directory and putting it somewhere other than the out directory. Reason being if you decide to do a lunch full-eng after you did the lunch sdk-eng, and then proceed to make, it will force a make cleaninstall and that will basically do a rm -rf on the out directory, deleting all of your SDK and any other platforms you downloaded through the sdk manager.
After you've built the sdk, you now have the necessary tools and API's to build for the platform you repo'd. A word of warning is that it seems if you repo the master branch, it is labeled as "AOSP" for the version indicating to Eclipse that the minimum platform required is the one you just built and so if you want to run it on your device you'll need the full platform loaded onto it or it will show you are running a version earlier than AOSP (also called 'Preview'). Example, as of this writing the version of AOSP is 4.2.1 and the API level is 17 (An API level is just a set of functions/datastructures available for a particular release of Android OS, so for Level 17 it corresponds to 4.2, You can use a higher API than your target (accept in the case of AOSP Preview) and still make sure you are compatible, but you can't use a lower API and expect to have functions/datastructures that were only implemented in later versions of Android). If you have downloaded the Android SDK for API level 17 it will be 4.2, not 4.2.1. You will not be able to run your app that you built using the API level 17 "Preview" based on 4.2.1...on your 4.2 emulator (or device for that matter). You will need to use the emulator based on the AOSP Preview build.
So in short the AOSP contains the sources to build the SDK, but you can also get prebuilt SDK's if you don't want to go through and build each API level.
rpowell8 said:
If I repo the AOSP do I by default now have the SDK?
Click to expand...
Click to collapse
No, you have the components to /build/ the SDK
rpowell8 said:
Do I have to download it separately?
Click to expand...
Click to collapse
No, you can either build it from the AOSP, or you can download it separately.
rpowell8 said:
Or can I/Should I compile it from the AOSP?
Click to expand...
Click to collapse
Probably should if you're building against the latest android development, but I don't see the need if you are building apps for already released API levels.

[Q] Editing Android Kernel - HCE/NFC

I'm currently in the process of creating a custom version of AOSP that will edit the functionality of the Host-Card Emulation feature of Android, allowing me to manually set the AID produced when my device goes into emulation mode.
I've downloaded the Android source, and have located the files I think governs HCE functionality.
From the NFC System Service, I've located the following files:
"CardEmulationManager.java" and "HostEmulationManager.java" located in "/aosp/packages/apps/Nfc/src/com/android/nfc/cardemulation/"
And from the Android core framework, for the NFC API I have found:
"CardEmulation.java" located at "/frameworks/base/core/java/android/nfc/cardemulation/CardEmulation.java"
From here, i'm unsure how to get started in editing the code. I'm unsure of the interactions between the files, and how they are called at run (I.e. which functions in the file I should be looking at, how would I go about adding my own code/modifying existing code in the file)
Is there any documentation online about how these files work/are ran? Or how would I go about finding out on my own (Through debugger tools etc.)
I'm currently using Eclipse for Ubuntu, and will be developing for a Nexus 7

dot42 open source Xamarin alternative

dot42 is open source Xamarin alternative. You can create Android app using c#. You can grab latest stable version from official repository https://github.com/dot42/dot42. But developer Olaf Pettersen created many fixes and improvements on it own repository https://github.com/ninjasync/dot42. So I forked it, made some fixes, compiled and generated setup from Olaf repository. You can download it from my gdrive https://goo.gl/jxAHgF
Olaf ported some libraries to work with dot42: MVVM Cross, JSON .NET, OxyPlot etc. Check his repository.
If you have any question about how to compile your own version you can ask here.
Currently android 5.0 is not supported. Apk files not working.
Hi, I have already a game build in C so I can covert it in an apk file with this software? Is it possible? E.g. In one of game's folder there are file like
File ACT
File AIR
File CNS, DEF e SFF
Sent from my LG-D802 using Tapatalk 4 Beta

[Q] Issue using custom SDK for application development

Hi,
I have built a custom SDK (modifying SDK 23) and set its build version (API) to 50 (So as not to clash with the existing ones). I want to use custom libraries of this SDK in my Android Studio Application. For this purpose I want to compile the application against the SDK version 50(compileSdkVersion=50).
But when I change compileSdkVersion to 50, it gives dependency errors. The support libraries, needed by application, are not generated along with Sdk generation.
Need help regarding using this custom SDK in android application.

Categories

Resources