does android ndk accelerates hardware? - java

I am developing an android app that processes images. I tried android ndk before so i can code natively to speed up performance. But I discontinued using it because I can't fully understand the C language.
So I continue my app dev using Java code. I searched for easier and better solution to speed up the performance of my app without using native code and it was a success.
After sometime, i realized that the ndk wasn't remove from my project. I removed it and recompile my code so i can remove the cpp folder too. But when I test my app, it became very slowwwwww... I linked the ndk again and now the image processing is fast again.
My question is, how did that happen???

For processing images, usually C/C++ gives better image output than Java in desktop.
While programming in Android also i saw C/C++ Android NDK code gives better image output and faster than Android Java code.
This may be because of C/C++ code directly complies to native code where else java compiles to byte code and from byte code complies to native code by JNI.
And in NDK, .so files are created by Application Binary Interface(ABI) by that application machine code is directly interacted with the system at run time.

Related

how to write an android app with languages other than java

my title is a little different than what i try to say, i couldnt exactly tell what i mean.
as far as i know we develop android apps with android studio(and there were support for other ide s like eclipse before) you code it and make a gui app with drag and drop.
recently i tried to open source code of few android apps like whatsapp. i extracted the classes.dex file and checked the source code. it was written with java. but when i google "whatsapp" it says it is written with erlang.
my question is, how the code written with erlang turns to a java code? as far as i know you can make android apps with c++ too. since we dont have a translator for languages, how is this being possible?
WhatsApps backend is written in Erlang, not the app
https://www.quora.com/Is-WhatsApp-fully-written-in-Erlang
Android uses the Java Virtual Machine (JVM) runtime. To run Android apps on a phone you either need to write them in a JVM language (Java, Kotlin, Scala), or write them in another language and that has a rumtime interpreter on the device (Javascript + Android Webview, Flutter + Flutter Runtime)
You can write your app in just c++, but then you won't have any of the Android SDK available to you. You'd have to rebuild the entire view plaform (among other things). Flutter does this.
If you have more specific questions I'd be happy to answer them

Do supported devices for an android app depends on Java version the code written in?

I have many assumptions about android because I lack of knowledge of android internal.
I'm developing apps with Android Studio. I usually search code snippet for java instead of android.
For example I search "java read file into byte array" rather than "android read file into byte array" so search results show java code snippets.
But sometimes, I see something like - "JAVA 7+" or "java 6+" which I translate as - "this code only work if I'm writing for this version (or above) of java".
I'm running android studio with JRE version 8 so I'm sure that my code will work in android studio and my APK will be generated successfully. But I'm also afraid that if a device does not have that version of java, my APK will crash on that device. This is all because I have the following assumptions:
android is based on JAVA and XML.
so android has JRE or JDK internally.
that JRE or JDK version(6/7/8..) depends on what android version that device has. For example may be Jellybean has JRE 6 and Oreo has
JRE 8 etc (if it's true then what version has what?).
my app will crash if I compile code for JAVA 8 and my APK meets a device that runs on a lower version of JRE.
That are my assumptions, it's a long question so I couldn't search it using keywords. Please guide me (tell me which assumption is wrong and what is right).
Android is an Operating System and not a programming language. It provides its own framework. The Android SDK has tools and API's built for developing android applications and it uses the Java programming language to do this. Hence why a large portion of Java libraries is supported in Android.

The Bluestacks Android emulator is built using .Net?

I recently installed the Bluestacks Android emulator. I happened to look at the process running under ProcessExplorer and was surprised to see that it is a .NET application.
The HD-Frontend.exe is the Bluestacks UI process and is highlighted yellow because it has loaded the .NET framework. There are a number of other processes associated with Bluestacks and most are also .NET.
Opening the EXE in Reflector.NET also shows that it is .NET.
I thought Android was Java-based. What's going on here?
Android is Java-based, but that does not mean an Android emulator has to be written in Java -- just functionally emulate Android devices.
While BlueStack's site does not list any system requirements for its emulator that I could find, at least a couple sites -- e.g. Bazooka Apps and Android Emulator for PC -- mention .NET as a requirement.
Ultimately the proof of what's going on is right in the process list and Reflector results you found.
its an emulation tool whose job is to read the dex code respond to that how the android phone should respond and not to compile and run that dex so it could be on python or ruby also there is no boundation at all that you have to make android emulator on java becuase android is built upon java.

Is is possible to write app for iOS and move object-c code into Android?

Today I was speaking with PM. He said that the best way to solve problem "The same app working on iOS and Android" is to write object-c code for iOS and then use the same code in Android app (https://developer.android.com/tools/sdk/ndk/index.html). That approach (in his opinion) will give us DRY effect (have one code to maintain).
I was so shocked that I almost didn't say anything to it. But after some time I think about it and found some problems:
C++ != Object-C. It is possible to add o-c code as c++ code in Android?
(Let say that #1 is possible) How can I do layouts, activities, ect. in c++ for Android?
Also when we should / should not use Android NDK?
The short answer is no it's not possible. However http://www.apportable.com
Claims to enable you to compile your iOS app for Android - thus enabling you to use all of the code in your iPhone app.
However it doesn't work with everyframe work but does have hooks in to the Android SDK so you can still access those components. Worth looking at, and having a play with. I have but only half-heartly and you'd have to build the iOS app from the outset with the plan to use http://www.apportable.com as like I said it doesn't currently support all ios sdks and you'd need to work around that.
But that should answer your question.
As of 2016 app portable is no longer an option more info it appears Google killed the dream.
Objective C code will not compile with the NDK. But check out http://www.apportable.com/ it's a library that allows you to write code for Android in Objective-C. That could be what your boss was talking about.
C++ < Objective-c. Objective-c is built on top of a C compiler ... Just name the files with *.mm and write c/c++ code. Basically what you could do is write functions that you want to share across platforms in c++ and use them in an Android project via JNI wrappers.
You can not share code which uses ios system Frameworks (UIKit, CFNetwork, ...) directly.
If you want to write code for whole apps once, you could give it a shot with apportable.com, like others have pointed out.
You can use the GNUstep Android toolchain to use model code based on Foundation and CoreFoundation in an Android app, and then write a new UI layer that interacts with the Objective C model via native NDK calls on top of that (e.g. in Android Studio).

Compiling Java hardware API to run in Android.

I am a bit of a noob to Android.
I have a project that utilizes a sensor glove to input data in the from of sensor values to a device. The objective of my project is to interface this sensor glove with an Android device so that the information from the glove is sent wireleslly to the Android device where my application would do the necessary processing.
The glove came with a set of tools and APIs to program in Java with. My question is basically, can i compile my code written in java to work on the Android platform? I reference a set of Jar files in my original code. Will i be able to utilize the same Jar files when running my code in Android, or would i be able to compile the same java code to run in Android.
really appreciate the help,
If the jar contains compiled class files, it won't work. Your source code has to be compiled to work with the dalvik virtual machine, not java.
However, if you have the uncompiled class files, it will (likely) work with Android. Most standard Java libraries are also available on Android.

Categories