5 ms·
Yes, but the context here is Java or Kotlin running on Android, not embedded C. Or do some Android applications run embedded C with only a Java UI? I'm not an
by dotancohen 2y ago
Yes, but the context here is Java or Kotlin running on Android, not embedded C.
Or do some Android applications run embedded C with only a Java UI? I'm not an Android dev.
- saagarjha 2y agoAndroid apps can call into native code via JNI, which the platform supports.
- ignoramous 2y agoWonder if Android apps can also be fully native (C++)?
- extraduder_ire 2y agoI saw a project posted on here a while back about writing android apps with no java, only c. There is no good reason to do it, but it is apparently possible. https://github.com/cnlohr/rawdrawandroid https://github.com/cnlohr/rawdrawandroid
- fensgrim 2y agoIt is possible to have a project set up with a manifest which contains only a single activity with android.app.NativeActivity pointing to a .so, and zero lines of java/kotlin/flutter/whatever else - though your app initialization will go through usual hoops of spawning a java-based instance. Minimal example would be https://github.com/android/ndk-samples/blob/master/native-activity/app/src/main/AndroidManifest.xml https://github.com/android/ndk-samples/blob/master/native-ac..., though there are well established Qt based apps as well
- orf 2y agoYes, Android apps can and do have native libraries. Sometimes this can be part of a SDK, or otherwise out of the developers control.
- warkdarrior 2y agoApps written in Flutter/Dart and React Native/Javascript both compile to native code with only shims to interface with the Java UI framework.
- farmerbb 2y agoFlutter/Dart, yes, React Native/Javascript, no. With RN the app's code runs via an embedded JavaScript engine, and even when, say, Hermes is being used, it's still executing bytecode not native machine code. Also important to note that any code that runs on Android's ART runtime (i.e. Kotlin and/or Java) can get some or all of its code AOT-compiled to machine code by the OS, either upon app install (if the app ships with baseline profiles) or in the background while the device is idle and charging.
- david_allison 2y agoThe Android Native Development Kit (NDK) allows building native code libraries for Android (typically C/C++, but this can include Rust). These can then be loaded and accessed by JNI on the Java/Kotlin side * Brief overview of the NDK: https://developer.android.com/ndk/guides https://developer.android.com/ndk/guides * Guide to supporting 16KB page sizes with the NDK https://developer.android.com/guide/practices/page-sizes https://developer.android.com/guide/practices/page-sizes
- dotancohen 2y agoGood to know, thank you!
- fpoling 2y agoChrome browser on Android uses the same code base as Chrome on desktop including multi-process architecture. But it’s UI is in Java communicating with C++ using JNI.
- dotancohen 2y agoI had no idea, thank you!