This is my first S/O question, please be gentle!
I'd like to know more about porting C applications to native ARM for use on Android devices.
I can make simple programs using the prebuild toolchain which comes with the source, but how can I use this toolchain with applications which are more than one file and require configure and make?
This article explains it quite well:
http://davanum.wordpress.com/2007/12/09/android-invoke-jni-based-methods-bridging-cc-and-java/
Basically, you create a shared library like you normally do, wrap it with JNI and call it with native methods from Java.
At Google I/O they talked about introducing an "NDK" -- native development kit -- that should simplify the process of creating applications that use native (C) code.
It's worth noting a couple of things before you go too far down this route:
The NDK will provide limited functionality. It will be primarily intended to offer a way to run extremely time-sensitive code natively, but won't have access to the full system, nor will it provide an alternative application development model (you'll still need to write most of your app for Dalvik).
You can write native apps without the NDK, but you won't be able to distribute them to end-users using the conventional APK application package supported by the app store. It's really only a viable option if your app is being distributed as part of the carrier / OEM build - and even then isn't recommended.
Related
Is it Reccommended to use JNI and C++ Code to make a shared library code between IOS and Android ?
I'am asking this because i think it not just saves us plenty of wasted time for implementing same logic in both platforms but also we will have the speed of a C++ core Backing the logic-process of our modules.
Update :
I ask my question in another way :
is it recommended to share a C++ Library for core functions of Android And IOS versions of a similar app ? or it would be better to completely migrate the codes to a multiplatform language ?
Since I remember my needs back then, I know that hybrid apps were not an option, Also JNI is not used for making cross-platform apps but the best use is to drive hardware peripherals via native UNIX scripts for Android or run c++ code on Android. So if we omit PhoneGap, Appcelerator, Ionic etc we will be facing several cross-platform technologies that have attracted many developer attentions so far.
Xamarin:
The framework was founded by the same people who have created Mono, an Ecma standard-compliant, .NET Framework-compatible set of tools. Xamarin offers developers a single C# codebase that can be used to produce native apps for all major mobile operating systems.
Unlike many other frameworks, Xamarin has already been used by over 1.4 million developers from around the world. Thanks to Xamarin for Visual Studio, developers can take advantage of the power of Microsoft Visual Studio and all its advanced features, including code completion, IntelliSense, and debugging of apps on a simulator or a device. Xamarin Test Cloud makes it possible to instantly test apps on 2,000 real devices in the cloud. This is by far the best way how to deal with the heavy fragmentation of the Android ecosystem and released bug-free apps that work without any major issues.
But being honest I didn't enjoy my first time face-to-face meeting with Xamarin. There were so many bugs and also speed and performance problems were bothering.
React Native
React Native is developed by Facebook and used by Instagram, Airbnb, Walmart, Tesla, Baidu, and many other Fortune 500 companies. It is an open-source version of Facebook’s React JavaScript framework. Because React Native uses the same UI building blocks as regular iOS and Android apps, it’s impossible to distinguish a React Native app from an app built using Objective-C or Java. As soon as you update the source code, you can see the changes instantly manifest in an app preview window. Should you ever feel the urge to manually optimize certain parts of your application, React Native lets you combine native code with components written in Objective-C, Java, or Swift.
The ones I mentioned above are not the only options, but since now they are the most used frameworks between programmers. But beware that Flutter is being publicly announced by Google in Google IO and maybe it may be going to create a hit soon.
I am thinking about creating apps on Android using JRuby (or a suitable variant of Ruby for Android).
According to my research there are two current projects that support Ruby development on Android:
Ruboto
SL4A
From the FAQ of the Ruboto wiki on github it seems like Ruboto is ready for application development, but does not yet support JIT compilation, and the application has to be packaged with libraries which give it a big footprint (for mobile device installation).
I don't have enough knowledge about SL4A but it seems like SL4A also tries to run JRuby scripts on the JVM. But the main thing is that SL4A is still in alpha, so I don't know if it can be used for app development.
Can someone with a better knowledge of these platforms suggest which one should be used? Also, in the near future, which one has the better probability of becoming more mature in terms of JIT (performance), lower footprint, and better API access to Android?
Mirah, by the developer of JRuby, already with some production apps, is appropriate for Android. One can use the Android API directly while mentally converting the Java syntax as you do so to 'almost-Ruby', whose syntax it 'stole'. It adds no library files (instead, compiler syntax plugins are used) and it has literally exactly the same runtime speed as Java. So it features performance, zero footprint and ideal API access to Android.
hey guys, i am researching android app development, and i cant find much on building an app in C or C++, so my question is, is it possible to build an android app using only C or C++ ?
Yes, in the most recent versions of the NDK they've announced such a capability. Before that, you could have an app that's a thin layer of Java on top of a C/C++ NDK core.
The majority of the run-time library is still Java-based, and accessing it from C++ is not exactly straightforward. JNI exposes the Java world to C/C++ callers, but it does not look pretty.
You might consider one of the other cross-platform services (e.g. MoSync), but realize that they are also limited in the sense that they give you access to more generic language features. Advanced or new features, such as NFC are not yet supported. Further, if you are planning on deploying the app commercially, you may have to pay them a royalty. You can get a better amount of information at their site.
Sure, using the Android Native Developers Kit.
I have 6 months experience with Android, developing simple UI-based applications. Now I want to write applications targeting the Android core Kernel. For example, I want to develop a framework which is not present in Android. To achieve that, we have to write the code for the Kernel. I don't know where and how to start Android Kernel programming.
If anybody knows the way to start it please help me.
xda-developersA very awesome and very active place for anything smart smart phone related.
kernelnewbies
Generally good resource for starting out learning linux kernel(Which is what the android is built off of)
Building Android KernelAndroid Kernel Source
Linux kernel Online guide to driver development among many other related topics.
Update
For android source code you can check out one of the following...
or this question
or source.android.com
I personally dig this chrome plugin for browsing android source code.
If you are talking about platform level programming,i.e. framework extensions, native libraries and services there are a few places to start.
The first one is the new and updated official open source project page. The portions about contributing and porting provide some basic information on the platform architecture and what you need to work with the platform. The next step is to understand the build system for the platform and framework. There are some limited info available on the net if you google for it. The best way is probably to study some of the makefile templates available in the open source project in the build folder. For info on how to add your own modules using Android.mk files it is a good thing to study make files for existing projects such as the ones available in external in the open source projects.
Once you have gotten as far as the above. That is you know the basics of platform level development and how to build your own modules for the platform the next step is to study the framework extension example available in the open source project. Check out the vendor/sample/PlatformLibrary folder (edit, as of 2.2 the vendor stuff has moved to the device folder) in the open source project and read the readme file, study the code, build it and make sure you understand it. If you don't then JNI, shared libraries, the platform security model and the core framework are areas that could help you out.
I guess that since you are talking about kernel programming you are also looking for ways to hook up new hardware with the platform and expose that functionality using your framework extensions to the applications. Hardware is basically added as a standard Linux driver so getting it to work under Linux is a good first step. How to hook it into the Android framework after that depends on what type of hardware it is. You could either use a native process to control it (compare the camera service or radio daemon in the current platform) or just spawn a thread in the application that uses your framework extension. For hardware that does not require that much attention plugging it in using an Android HAL library could also be an option.
I hope that provides some initial pointers on where to look. The official mailing lists are otherwise the main source of info about platform level development. Especially Android porting and Android platform.
You should also check out http://pdk.android.com. I just found this site recently and it is extremely useful. I wish I knew about it sooner. I'm not sure how dedicated Google is to updating the site because as BMB mentioned the vendor stuff was moved to the device folder in 2.2 but there have been no changes to the PDK site to reflect that. Also, some of the links don't work but I was able to find all the pages by doing a site search in Google.
The best and very first place to start would be Google’s documentation on android
https://source.android.com/docs/core/architecture/kernel
Then kernel building
https://source.android.com/docs/setup/build/building-kernels
Xda isn’t so great for kernel creation but is good for kernel modification and backporting. Mostly what they do there is provide newer versions of android to older phones rom modification and changing the battery animation in the boot.img
Google also goes over the development of new things for an existing kernel.
It’s best to start at the begining,
Personally I started at xda and went backwards which took WAY longer and just complicated my setup process.
I'm fairly new to Android and have gone through the basic tutorials. I thought I'd dig a little deeper and downloaded the source code to some of the "native" Android apps, like IM, Email, Voice Dialer, etc.
In importing the source of these native apps into Eclipse, I found that they reference classes that are not in the 2.1 API, i.e. classes such as android.content.Entity, android.net.http.DomainNameChecker, etc. As a result, I can't compile and play with this code.
So is there is a "hidden" API that the native apps use that is not available to the regular app developers? Is there a "native" SDK I can use to import these classes?
David
As with all hidden API:s these are hidden for a reason and that is that they are used by the framework or specialized applications and are not guaranteed stable or suitable for general development. It is not advisable to use non-supported API:s for your applications since they might break on future releases etc. The ones that you mention are part of the framework and used internally by the Android system.
That said, if you just want to explore Android you may build your apps as part of the platform build system and test them with your own build from the open source projects.
The article "Using internal (com.android.internal) and hidden (#hide) APIs" by user inazaruk shows you step by step a method to import hidden Android APIs.