From 3d2a0e3eb272c93ad0450a38611c4784863eb742 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Wed, 24 Feb 2021 06:18:11 -0800 Subject: [PATCH] Enable prefab for fbjni integration (#1941) Summary: I'm in the progress of releasing a prefab-enabled FBJNI release. This dramatically reduces the hackery around integrating with separately released native libraries. This will fail until the release is actually out. Pull Request resolved: https://github.com/facebook/flipper/pull/1941 Test Plan: `./gradlew :sample:installDebug` works as before. Once the release is out, we need to check if this creates any problems with RN but because we advice to exclude the dependency, I expect it not to cause any trouble. Reviewed By: mweststrate Differential Revision: D26545104 Pulled By: passy fbshipit-source-id: 1e21fa1816f28e2fcb52da68863fabc8bc625136 --- android/CMakeLists.txt | 10 ++-------- android/build.gradle | 15 ++++++++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt index 540b9a44b..1812146ed 100644 --- a/android/CMakeLists.txt +++ b/android/CMakeLists.txt @@ -49,18 +49,12 @@ set(libflipper_build_DIR ${build_DIR}/libflipper/${ANDROID_ABI}) set(libfolly_build_DIR ${build_DIR}/libfolly/${ANDROID_ABI}) file(MAKE_DIRECTORY ${build_DIR}) -file(GLOB libfbjni_link_DIRS "${build_DIR}/fbjni*/jni/${ANDROID_ABI}") -file(GLOB libfbjni_include_DIRS "${build_DIR}/fbjni-*-headers.jar/") - -# Without NO_CMAKE_FIND_ROOT_PATH, this will for some bizarre reason only look -# in the NDK folder. -find_library(FBJNI_LIBRARY fbjni PATHS ${libfbjni_link_DIRS} NO_CMAKE_FIND_ROOT_PATH) +find_package(fbjni REQUIRED CONFIG) add_subdirectory(${libflipper_DIR} ${libflipper_build_DIR}) target_include_directories(${PACKAGE_NAME} PRIVATE ${libjnihack_DIR} - ${libfbjni_include_DIRS} ${libflipper_DIR} ${libfolly_DIR} ${glog_DIR} @@ -73,4 +67,4 @@ target_include_directories(${PACKAGE_NAME} PRIVATE ${LIBEVENT_DIR}/include/event2 ) -target_link_libraries(${PACKAGE_NAME} ${FBJNI_LIBRARY} flippercpp) +target_link_libraries(${PACKAGE_NAME} fbjni::fbjni flippercpp) diff --git a/android/build.gradle b/android/build.gradle index e50598fd2..7130ae161 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -28,7 +28,7 @@ android { externalNativeBuild { cmake { - arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static' + arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_shared' targets 'flipper', 'event_shared', 'event_extra_shared', 'event_core_shared' } } @@ -51,6 +51,14 @@ android { } } + buildFeatures { + prefab true + } + + packagingOptions { + exclude("**/libfbjni.so") + exclude("**/libc++_shared.so") + } externalNativeBuild { cmake { @@ -60,10 +68,7 @@ android { dependencies { compileOnly deps.proguardAnnotations - // Temporary until we upgrade to prefabs: https://developer.android.com/studio/releases/gradle-plugin#native-dependencies - implementation 'com.facebook.fbjni:fbjni-java-only:0.0.4' - extractHeaders 'com.facebook.fbjni:fbjni:0.0.4:headers' - extractJNI 'com.facebook.fbjni:fbjni:0.0.4' + implementation 'com.facebook.fbjni:fbjni:0.1.0' implementation deps.soloader implementation deps.jsr305 implementation deps.supportAppCompat