Skip to content

Commit

Permalink
docs(android): 补充文档
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Aug 8, 2024
1 parent 112c07a commit 97c05c4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@

/target
/deploy

**/jniLibs/
32 changes: 32 additions & 0 deletions android/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# android 对话实现

使用 [cargo-ndk](https://crates.io/crates/cargo-ndk) 编译:

```shell
cargo ndk -t armeabi-v7a -t arm64-v8a -t x86_64 -o jniLibs build --package android --release
```

> **NOTICE** 需要按 cargo-ndk 描述配置 NDK 和 Android 工具链。
将在项目目录生成 jniLibs 目录,将这个目录拷贝到 android 项目的 *app/src/main* 目录中。并添加这个 Java 源文件:

```java
package org.infinitensor.lm;

public class Native {
public native static void init(String model_path);
public native static void start(String prompt);
public native static String decode();
}
```

调用这些代码后:

```kotlin
try {
System.loadLibrary("android")
} catch (e: UnsatisfiedLinkError) {
throw RuntimeException("Native library not found", e)
}
```

即可使用 `Native` 类。

0 comments on commit 97c05c4

Please sign in to comment.