Skip to content

Commit 3e6fc22

Browse files
authored
fix: android CMakeLists.txt for newer versions of react-native (#74)
* chore: rename android library name * fix: android CMakeLists.txt * chore: use java 11 on CI * chore: attempt to fix android CI * chore: no verbose makefile and no specific version for android implementations * chore: verify lint report * revert: specific version 0.71.6 on android/build.gradle * chore: android/build/reports/lint-results-debug.xml
1 parent bf2703f commit 3e6fc22

File tree

9 files changed

+42
-29
lines changed

9 files changed

+42
-29
lines changed

.github/workflows/build-android.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v2
2727

28-
- name: Setup JDK 1.8
28+
- name: Setup JDK 11
2929
uses: actions/setup-java@v1
3030
with:
31-
java-version: 1.8
31+
java-version: 11
3232

3333
- name: Get yarn cache directory path
3434
id: yarn-cache-dir-path

.github/workflows/validate-android.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
working-directory: ./android
2424
steps:
2525
- uses: actions/checkout@v2
26-
- name: Setup JDK 1.8
26+
- name: Setup JDK 11
2727
uses: actions/setup-java@v1
2828
with:
29-
java-version: 1.8
29+
java-version: 11
3030

3131
- name: Get yarn cache directory path
3232
id: yarn-cache-dir-path
@@ -55,11 +55,17 @@ jobs:
5555
${{ runner.os }}-gradle-
5656
- name: Run Gradle Lint
5757
run: ./gradlew lint --build-cache
58-
58+
- name: Verify lint report exists
59+
run: |
60+
ls -R build/reports
61+
if [ ! -f "build/reports/lint-results-debug.xml" ]; then
62+
echo "Lint report not found!"
63+
exit 1
64+
fi
5965
- name: Parse Gradle Lint Report
6066
uses: yutailang0119/[email protected]
6167
with:
62-
xml_path: android/build/reports/lint-results.xml
68+
xml_path: android/build/reports/lint-results-debug.xml
6369
# ktlint:
6470
# name: Kotlin Lint
6571
# runs-on: ubuntu-latest

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ yarn test
5353

5454
To edit the Objective-C files, open `example/ios/BigNumberExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-bignumber`.
5555

56-
To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativeBigNumber` under `Android`.
56+
To edit the Kotlin files, open `example/android` in Android studio and find the source files at `react-native-bignumber` under `Android`.
5757

5858
### Commit message convention
5959

android/CMakeLists.txt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
project("react-native-bignumber")
22
cmake_minimum_required(VERSION 3.9.0)
33

4-
set(PACKAGE_NAME "reactnativeBigNumber")
4+
set(PACKAGE_NAME "react-native-bignumber")
55
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
66
set(CMAKE_CXX_STANDARD 17)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
78

89
# Consume shared libraries and headers from prefabs
910
find_package(fbjni REQUIRED CONFIG)
1011
find_package(ReactAndroid REQUIRED CONFIG)
12+
find_package(openssl REQUIRED CONFIG)
13+
find_library(LOG_LIB log)
1114

1215
include_directories(
1316
"../cpp"
@@ -45,24 +48,26 @@ set_target_properties(
4548
POSITION_INDEPENDENT_CODE ON
4649
)
4750

48-
file(GLOB LIBRN_DIR "${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}")
49-
50-
find_library(
51-
log-lib
52-
log
53-
)
54-
55-
find_package(openssl REQUIRED CONFIG)
56-
5751
target_link_libraries(
5852
${PACKAGE_NAME}
59-
ReactAndroid::turbomodulejsijni
53+
${LOG_LIB}
6054
fbjni::fbjni
61-
${log-lib}
6255
ReactAndroid::jsi
63-
ReactAndroid::reactnativejni
64-
ReactAndroid::react_nativemodule_core
6556
android
6657
openssl::crypto
6758
openssl::ssl
6859
)
60+
61+
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
62+
target_link_libraries(
63+
${PACKAGE_NAME}
64+
ReactAndroid::reactnative
65+
)
66+
else ()
67+
target_link_libraries(
68+
${PACKAGE_NAME}
69+
ReactAndroid::reactnativejni
70+
ReactAndroid::turbomodulejsijni
71+
ReactAndroid::react_nativemodule_core
72+
)
73+
endif ()

android/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ android {
9090
'**/libreactnativejni.so',
9191
'**/libjsi.so',
9292
'**/libreact_nativemodule_core.so',
93-
'**/libturbomodulejsijni.so'
93+
'**/libturbomodulejsijni.so',
94+
'**/libreactnative.so'
9495
]
9596
}
9697
resources {
9798
excludes += ['**/MANIFEST.MF']
9899
}
100+
exclude 'META-INF/LICENSE.md'
99101
}
100102

101103

@@ -126,6 +128,6 @@ dependencies {
126128
// https://mvnrepository.com/artifact/com.android.ndk.thirdparty/openssl
127129
implementation 'com.android.ndk.thirdparty:openssl:1.1.1l-beta-1'
128130

129-
implementation "com.facebook.react:react-android:"
130-
implementation "com.facebook.react:hermes-android:"
131+
implementation "com.facebook.react:react-android:0.71.6"
132+
implementation "com.facebook.react:hermes-android:0.71.6"
131133
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

android/src/main/java/com/margelo/bignumber/BigNumberModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public boolean install() {
4141
return false;
4242
}
4343
Log.i(NAME, "Loading C++ library...");
44-
System.loadLibrary("reactnativeBigNumber");
44+
System.loadLibrary("react-native-bignumber");
4545

4646
JavaScriptContextHolder jsContext = getReactApplicationContext().getJavaScriptContextHolder();
4747
CallInvokerHolderImpl jsCallInvokerHolder = (CallInvokerHolderImpl) getReactApplicationContext()

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ dependencies {
166166
implementation jscFlavor
167167
}
168168

169-
implementation project(':reactnativeBigNumber')
169+
implementation project(':react-native-bignumber')
170170
}
171171

172172
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

example/android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ apply from: file("../node_modules/@react-native-community/cli-platform-android/n
33
include ':app'
44
includeBuild('../node_modules/react-native-gradle-plugin')
55

6-
include ':reactnativeBigNumber'
7-
project(':reactnativeBigNumber').projectDir = new File(rootProject.projectDir, '../../android')
6+
include ':react-native-bignumber'
7+
project(':react-native-bignumber').projectDir = new File(rootProject.projectDir, '../../android')

0 commit comments

Comments
 (0)