From 1501abc0020060c97c1907e2328fa8af881c4fd0 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Sun, 21 Feb 2021 04:30:33 -0800 Subject: [PATCH] Add updated integration instructions (#46) Summary: Added a *much shorter* set of instructions to integrate with the build plugin 4.0. Pull Request resolved: https://github.com/facebookincubator/fbjni/pull/46 Test Plan: _eyes Reviewed By: fabiomassimo Differential Revision: D26545014 Pulled By: passy fbshipit-source-id: 67f111e60fc193d75351b70976abb452e33bf943 --- first-party/fbjni/docs/android_setup.md | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/first-party/fbjni/docs/android_setup.md b/first-party/fbjni/docs/android_setup.md index 574830bdd0e..692bd44fb7d 100644 --- a/first-party/fbjni/docs/android_setup.md +++ b/first-party/fbjni/docs/android_setup.md @@ -1,5 +1,37 @@ ## Android Build Setup +**These instructions require the Android Gradle Build Plugin 4.0.0 or newer +as it relies on the new [prefab](https://android-developers.googleblog.com/2020/02/native-dependencies-in-android-studio-40.html) integration. +Check below for a pre-4.0.0 workaround.** + +```groovy +repositories { + maven { + mavenCentral() + } +} + +android { + dependencies { + implementation 'com.facebook.fbjni:fbjni:0.1.0' + } +} +``` + +Now, in your CMake setup, you can refer to the `fbjni` package. The header files (e.g. `fbjni.h`) +will available implicitly. + +```cmake +set(build_DIR ${CMAKE_SOURCE_DIR}/build) +set(PACKAGE_NAME "myapp") + +find_package(fbjni REQUIRED CONFIG) + +target_link_libraries(${PACKAGE_NAME} fbjni::fbjni mylibrary) +``` + +## Android Build Setup (pre-4.0.0) + The Android Gradle plugin does not provide built-in support for artifacts that include native libraries (for linking against) and header files. Because of that, some manual additions to your build system are required. The following @@ -73,6 +105,7 @@ Now, in your CMake setup, you can refer to the extracted paths: ```cmake set(build_DIR ${CMAKE_SOURCE_DIR}/build) +set(PACKAGE_NAME "myapp") file(GLOB libfbjni_link_DIRS "${build_DIR}/fbjni*.aar/jni/${ANDROID_ABI}") file(GLOB libfbjni_include_DIRS "${build_DIR}/fbjni-*-headers.jar/")