LiteRT v2 (CompiledModel) C++ SDK for Android

You can also use prebuilt LiteRT Maven packages for your Android C++ libraries without building the entire LiteRT source tree. The integration is done with CMake.

The following shows basic steps to use LiteRT CompiledModel API in your C++ NDK code.

Integrate LiteRT C++ SDK

Choose a folder to host LiteRT C++ SDK. We'll refer to it as <litert_cc_sdk_location>.

  1. Download C++ SDK

    You need to prepare the necessary files (CMakeLists.txt, source and header files) from LiteRT C++ SDK zip file under <litert_cc_sdk_location>.

    wget https://github.com/google-ai-edge/LiteRT/releases/download/<litert_version>/litert_cc_sdk.zip unzip litert_cc_sdk.zip -d <litert_cc_sdk_location> 
  2. Place libLiteRt.so from the LiteRT Maven package under <litert_cc_sdk_location>.

    cp <path_to_prebuilt_lib>/libLiteRt.so <litert_cc_sdk_location>/litert_cc_sdk/ 
  3. Update your CMakeLists.txt to use LiteRT API.

    add_subdirectory("<litert_cc_sdk_location>" "<litert_cc_sdk_location>/build") include_directories("<litert_cc_sdk_location>") target_link_libraries(${CMAKE_PROJECT_NAME}  # Use `litert_cc_api` for LiteRT C++ SDK  litert_cc_api  android  log) 
  4. Update your build.gradle.kts to configure LiteRT C++ SDK.

     externalNativeBuild { cmake { path = file("<litert_cc_sdk_location>/CMakeLists.txt") version = "3.22.1" } }