Skip to content

Latest commit

ย 

History

History
60 lines (45 loc) ยท 1.46 KB

README.md

File metadata and controls

60 lines (45 loc) ยท 1.46 KB

Android Examples

Compile Logic Library

  1. Install Rust toolchains and protoc

  2. In project's root directory, run

    make kotlin-pb
    make logic-android-release

    Follow the instructions from the output of commands above to install missing components, if any.

You should see generated Kotlin sources under android/com/bugenzhao/mnga/protos/, and dynamic-linked libraries for JNI under out/libs/jniLibs/.

Prepare Android Project

Create a Android module named logic

Put output files from last step into their places. Your project structure should look like the following:

logic
โ”œโ”€โ”€ build.gradle
โ””โ”€โ”€ src
    โ”œโ”€โ”€ main
    โ”‚ย ย  โ”œโ”€โ”€ AndroidManifest.xml
    โ”‚   โ”œโ”€โ”€ java
    โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ com.bugenzhao.mnga
    โ”‚   โ”‚      โ”œโ”€โ”€ protos
    โ”‚   โ”‚      โ””โ”€โ”€ logic.kt
    โ”‚ย ย  โ””โ”€โ”€ jniLibs
    โ”‚ย ย      โ”œโ”€โ”€ arm64-v8a
    โ”‚ย ย      โ”œโ”€โ”€ x86
    โ”‚ย ย      โ””โ”€โ”€ x86_64
    โ””โ”€โ”€ test
        โ””โ”€โ”€ java

You may check logic.kt for an example of logic wrapper and usage to the logic interfaces.

In module-level build.gradle

dependencies {
    implementation ('com.google.protobuf:protobuf-kotlin:3.17.0') {
        exclude group: "com.google.protobuf", module: "protobuf-java"
    }
}

In project-level build.gradle

dependencies {
    classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.17'
}