Skip to content

Commit

Permalink
[native] Fix Android glog build errors
Browse files Browse the repository at this point in the history
Summary:
Atul and I noticed an issue compiling glog. It was [this error](google/glog#355 (comment)), and it should've been addressed by `BUILD_TESTING`, but for some reason it wasn't.

I also noticed that the issue would only consistently repro after cleaning all build artifacts. I'm still not sure why that is.

To debug the issue I ran `./gradlew` with the `-i` flag. I saw this in the output:

```
evaluate library symbolize_unittest (armeabi-v7a)
No CMake version was specified in build.gradle. Using default version 3.10.2.
building target executable symbolize_unittest because no targets are specified.
```

This led me to realize that because we weren't specifying `targets`, Gradle was configured to separately build `glog` directly (instead of through our `CMakeLists.txt`), and that was what was causing the issue.

Test Plan:
Make sure Android can build after cleaning all build artifacts:

```
./gradlew clean && rm -rf build && rm -rf app/build && rm -rf app/.cxx && ./gradlew app:installDebug -PreactNativeDevServerPort=8081
```

Reviewers: karol-bisztyga, atul

Reviewed By: atul

Subscribers: KatPo, palys-swm, Adrian

Differential Revision: https://phabricator.ashoat.com/D1231
  • Loading branch information
Ashoat committed May 24, 2021
1 parent 3e9b1b3 commit 3590769
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion native/android/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ cmake_minimum_required(VERSION 3.4.1)
set(PACKAGE_NAME "comm_jni_module")

find_package(fbjni REQUIRED CONFIG)
set(BUILD_TESTING false)

set(BUILD_TESTING OFF)
set(WITH_GTEST OFF CACHE BOOL "Use googletest" FORCE)
set(WITH_GFLAGS OFF CACHE BOOL "Use gflags" FORCE)
add_subdirectory(./build/third-party-ndk/glog/glog-0.5.0/)

include_directories(
Expand Down
1 change: 1 addition & 0 deletions native/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ android {
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared"
targets "comm_jni_module"
}
}
}
Expand Down

0 comments on commit 3590769

Please sign in to comment.