mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Add Chiaki Lib to Android
This commit is contained in:
parent
dbe4839165
commit
7fb4c67f33
11 changed files with 142 additions and 7 deletions
5
android/app/CMakeLists.txt
Normal file
5
android/app/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
add_library(chiaki-jni SHARED src/main/cpp/chiaki-jni.c)
|
||||
target_link_libraries(chiaki-jni chiaki-lib)
|
|
@ -13,6 +13,23 @@ android {
|
|||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DCHIAKI_ENABLE_TESTS=OFF",
|
||||
"-DCHIAKI_ENABLE_CLI=OFF",
|
||||
"-DCHIAKI_ENABLE_GUI=OFF",
|
||||
"-DCHIAKI_ENABLE_ANDROID=ON",
|
||||
"-DCHIAKI_LIB_ENABLE_OPUS=OFF",
|
||||
"-DCHIAKI_LIB_OPENSSL_EXTERNAL_PROJECT=ON",
|
||||
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||
}
|
||||
}
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
version "3.10.2+"
|
||||
path "../../CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
|
9
android/app/src/main/cpp/chiaki-jni.c
Normal file
9
android/app/src/main/cpp/chiaki-jni.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
|
||||
#include <jni.h>
|
||||
|
||||
#include <chiaki/common.h>
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_com_metallic_chiaki_lib_Chiaki_stringFromJNI(JNIEnv* env, jobject thiz)
|
||||
{
|
||||
return (*env)->NewStringUTF(env, chiaki_error_string(CHIAKI_ERR_SUCCESS));
|
||||
}
|
|
@ -2,6 +2,8 @@ package com.metallic.chiaki
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.metallic.chiaki.lib.Chiaki
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
||||
class MainActivity : AppCompatActivity()
|
||||
{
|
||||
|
@ -9,5 +11,7 @@ class MainActivity : AppCompatActivity()
|
|||
{
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
testTextView.text = Chiaki.stringFromJNI()
|
||||
}
|
||||
}
|
||||
|
|
14
android/app/src/main/java/com/metallic/chiaki/lib/Chiaki.kt
Normal file
14
android/app/src/main/java/com/metallic/chiaki/lib/Chiaki.kt
Normal file
|
@ -0,0 +1,14 @@
|
|||
package com.metallic.chiaki.lib
|
||||
|
||||
class Chiaki
|
||||
{
|
||||
companion object
|
||||
{
|
||||
init
|
||||
{
|
||||
System.loadLibrary("chiaki-jni")
|
||||
}
|
||||
|
||||
@JvmStatic external fun stringFromJNI(): String
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/testTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue