Skip to content

Commit

Permalink
Add updated integration instructions (#46)
Browse files Browse the repository at this point in the history
Summary:
Added a *much shorter* set of instructions to integrate with
the build plugin 4.0.

Pull Request resolved: facebookincubator/fbjni#46

Test Plan: _eyes

Reviewed By: fabiomassimo

Differential Revision: D26545014

Pulled By: passy

fbshipit-source-id: 67f111e60fc193d75351b70976abb452e33bf943
  • Loading branch information
passy authored and facebook-github-bot committed Feb 21, 2021
1 parent af2b86f commit 1501abc
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions first-party/fbjni/docs/android_setup.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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/")
Expand Down

0 comments on commit 1501abc

Please sign in to comment.