Bindings to the JNI library on Android for Kotlin/Native

Overview

JNI Utils

using this library:

implementation("io.github.landrynorris:jni-utils:0.0.1-alpha01")

This library provides bindings to the JNI library on Android.

The primary motivator of this library is the syntax for calling a method on JNIEnvVar

env.pointed.pointed?.SetObjectField?.invoke(env, fieldId, value)

This library allows you to write

env.setObjectField(fieldId, value)

Or take for example, converting a Kotlin String to a jstring:

//Raw JNI library
memScoped {
    env.pointed.pointed?.newString?.invoke(myString.wcstr.ptr, length)
}

//This library
myString.toJString(env)

Registering natives

This library provides a DSL for registering JNI methods.

env.registerNatives {
    clazz = env.findClass("io.github.landrynorris.sample.JniBridge".signature())

    method("buttonClicked") {
        signature = signature(::buttonClicked)
        function = staticCFunction(::buttonClicked)
    }

    method("getText") {
        signature = Signature(listOf(Long), String).toString()
        function = staticCFunction(::getText)
    }
}

You must provide a clazz value in the DSL.

There are two ways of defining the signature:

  1. the Signature() constructor. Provide a list of parameter signatures and a single return signature. The Signature#toString() method creates a signature that the JNI can recognize.
  2. For simple methods (jstring, jobject, etc. are not currently supported), you can use the signature(Function) method to automatically create a signature.
You might also like...
Simple library to decompress files .zip, .rar, .cbz, .cbr in React Native.
Simple library to decompress files .zip, .rar, .cbz, .cbr in React Native.

Uncompress React Native Simple library to decompress files .zip, .rar, .cbz and .cbr in React Native. Installation yarn add uncompress-react-native o

ShopApp - A Native Android Shop app with kotlin
ShopApp - A Native Android Shop app with kotlin

A Native Android Shop app. Light Theme Dark Theme I've used: Kotlin The MVVM architecture pattern Jetpack Compose Hilt for dependency injectio

An advanced Kotlin (Android Native) application that uses SOLID architectural principles, consumes a RESTFUL Service, downloads & images using best practices
An advanced Kotlin (Android Native) application that uses SOLID architectural principles, consumes a RESTFUL Service, downloads & images using best practices

Dog-Playground Kotlin An advanced Kotlin (Android Native) application that uses SOLID architectural principles, consumes a RESTFUL Service, downloads

KotlinSample - Template project for building a GTK3 Kotlin/Native app against the elementary Flatpak runtime

GTK3 Kotlin/Native Sample This is a working example of how to write and build a

CMPLR-Native - A blogging mobile application built with Kotlin using MVC design pattern and Take some advantage of Jetpack , View & Data Binding UML model and code examples of design patterns for Kotlin/Native. The model is created with Astah.
UML model and code examples of design patterns for Kotlin/Native. The model is created with Astah.

Design Pattern Examples in Kotlin/Native Model and code examples of GoF Design Patterns for Kotlin/Native. This project is available for the following

๐ŸŒ„ Photo editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and PhotoEditor (Android)
๐ŸŒ„ Photo editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and PhotoEditor (Android)

React Native Photo Editor (RNPE) ๐ŸŒ„ Image editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and Ph

Initiate immediate phone call for React Native on iOS and Android.

react-native-immediate-call-library Initiate immediate phone call for React Native on iOS and Android. Getting started Using npm: npm install react-na

Clothes shop native android app
Clothes shop native android app

ShopApp I built this clothes shop native android app in which I tried to implement clean architecture principles and use Jetpack Compose to create the

Comments
  • Compiler API

    Compiler API

    The Kotlin compiler API is in a weird place currently. There is a compiler SDK currently, but it will be replaced with the K2 SDK in the near future. I will postpone writing a compiler plugin until K2 is in beta. This plugin will likely attempt to bridge Native and Java methods automatically, but I'm not sure yet which direction.

    opened by LandryNorris 0
Releases(0.0.1-alpha02)
Owner
Landry Norris
I am a student at the University of Texas at Dallas majoring in Electrical Engineering while programming on the side.
Landry Norris
This little project provides Kotlin bindings for the popular tree-sitter library

kotlintree This little project provides Kotlin bindings for the popular tree-sitter library. Currently it only supports the Kotlin JVM target, but Kot

Christian Banse 23 Nov 28, 2022
๐Ÿ“ฒ๐Ÿ’ฌ react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in android and iOS devices.

React Native Fontext react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in androi

mroads 9 Dec 3, 2021
A Python native extension written in Kotlin Native

Kotlin Python Ext This is a proof of concept for a Python extension in Kotlin. It is recommended to read the Official Python C API Documentation befor

Martmists 20 Jun 22, 2022
Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in the official package.

@mccsoft/react-native-matomo Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in th

MCC Soft 4 Dec 29, 2022
Native-loader - Safely load native libraries in Java

Native Loader ??๏ธ Safe native loading in Java based off of the native-loader use

Mixtape 1 Oct 19, 2022
React-native-user-interface - Change React Native userinterface at runtime

react-native-user-interface change RN userinterface at runtime. Installation npm

Ahmed Eid 0 Jan 11, 2022
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

Bartล‚omiej Klocek 60 Dec 29, 2022
A Kotlin binding to webview, a tiny cross-platform webview library, supports Java and Native.

webviewko provides a Kotlin/JVM and a Kotlin/Native(experimental) binding to webview, a tiny cross-platform webview library to build modern cross-platform GUIs using WebView2, WebKit and WebKitGTK.

Winterreisender 17 Dec 30, 2022
Android native news App using API from thenewsapi.com and Retrofit Library

FlashBytes-Android-News-App Android Material Design News App using API from https://www.thenewsapi.com/ and Retrofit Library Screen Splash, Onboard Sc

claudysoft 4 Nov 11, 2022
Library to read incoming SMS in Android for Expo (React Native)

react-native-expo-read-sms Maintainers maniac-tech Active maintainer Installation Install this in your managed Expo project by running this command: $

Abhishek Jain 15 Jan 2, 2023