Closed mutablestudio closed 4 years ago
I was able to fix this by updating node_modules/react-native-sodium/android/build.gradle
:
13 compileSdkVersion 28
14 buildToolsVersion "28.0.3"
15 defaultConfig {
16 minSdkVersion 16
17 targetSdkVersion 28
I also changed node_modules/react-native-sodium/android/CMakeLists.txt
:
cmake_minimum_required(VERSION 3.4.1)
set(ARCH_DIR ${ANDROID_ARCH_NAME})
if( ANDROID_ABI STREQUAL "armeabi-v7a")
set( ARCH_DIR "armv7-a" )
elseif ( ANDROID_ABI STREQUAL "arm64-v8a")
set( ARCH_DIR "armv8-a" )
elseif ( ANDROID_ABI STREQUAL "x86")
set ( ARCH_DIR "i686" )
elseif ( ANDROID_ABI STREQUAL "x86_64")
set ( ARCH_DIR "westmere" )
endif()
#message(WARNING "ANDROID_ARCH_NAME=\"${ANDROID_ARCH_NAME}\" ARCH_DIR=\"${ARCH_DIR}\" ANDROID_ABI=\"${ANDROID_ABI}\"")
#if( ARCH_DIR STREQUAL "arm" )
# set( ARCH_DIR "armv6" )
#elseif( ARCH_DIR STREQUAL "arm64" )
# set( ARCH_DIR "armv8-a" )
#elseif( ARCH_DIR STREQUAL "x86" )
# set( ARCH_DIR "i686" )
#elseif( ARCH_DIR STREQUAL "x86_64" )
# set( ARCH_DIR "westmere" )
#elseif( ARCH_DIR STREQUAL "mips" )
# set( ARCH_DIR "mips32" )
#elseif( ARCH_DIR STREQUAL "mips64" )
# set( ARCH_DIR "mips64r6" )
#endif()
add_library(sodium SHARED IMPORTED)
include_directories( ${PROJECT_SOURCE_DIR}/../libsodium/libsodium-android-${ARCH_DIR}/include/ )
set_target_properties( sodium PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../libsodium/libsodium-android-${ARCH_DIR}/lib/libsodium.so )
file(COPY ${PROJECT_SOURCE_DIR}/../libsodium/libsodium-android-${ARCH_DIR}/lib/libsodium.so DESTINATION "${PROJECT_SOURCE_DIR}/lib/${ANDROID_ABI}")
add_library(sodium-jni SHARED src/main/cpp/sodium-jni.c)
target_link_libraries(sodium-jni sodium)
Please note that I'm not an expert, but this worked for me (RN 0.60.6).
I have also created a patch:
patch -p0 < react-native-sodium.patch
react-native-sodium.patch
diff -Naur node_modules/react-native-sodium/android/CMakeLists.txt node_modules/react-native-sodium.new/android/CMakeLists.txt
--- node_modules/react-native-sodium/android/CMakeLists.txt 2019-09-20 13:15:05.000000000 +0200
+++ node_modules/react-native-sodium.new/android/CMakeLists.txt 2019-10-09 10:41:55.000000000 +0200
@@ -2,21 +2,16 @@
set(ARCH_DIR ${ANDROID_ARCH_NAME})
-if( ARCH_DIR STREQUAL "arm" )
- set( ARCH_DIR "armv6" )
-elseif( ARCH_DIR STREQUAL "arm64" )
+if( ANDROID_ABI STREQUAL "armeabi-v7a")
+ set( ARCH_DIR "armv7-a" )
+elseif ( ANDROID_ABI STREQUAL "arm64-v8a")
set( ARCH_DIR "armv8-a" )
-elseif( ARCH_DIR STREQUAL "x86" )
- set( ARCH_DIR "i686" )
-elseif( ARCH_DIR STREQUAL "x86_64" )
- set( ARCH_DIR "westmere" )
-elseif( ARCH_DIR STREQUAL "mips" )
- set( ARCH_DIR "mips32" )
-elseif( ARCH_DIR STREQUAL "mips64" )
- set( ARCH_DIR "mips64r6" )
+elseif ( ANDROID_ABI STREQUAL "x86")
+ set ( ARCH_DIR "i686" )
+elseif ( ANDROID_ABI STREQUAL "x86_64")
+ set ( ARCH_DIR "westmere" )
endif()
-
add_library(sodium SHARED IMPORTED)
include_directories( ${PROJECT_SOURCE_DIR}/../libsodium/libsodium-android-${ARCH_DIR}/include/ )
set_target_properties( sodium PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../libsodium/libsodium-android-${ARCH_DIR}/lib/libsodium.so )
diff -Naur node_modules/react-native-sodium/android/build.gradle node_modules/react-native-sodium.new/android/build.gradle
--- node_modules/react-native-sodium/android/build.gradle 2019-09-20 13:15:05.000000000 +0200
+++ node_modules/react-native-sodium.new/android/build.gradle 2019-10-09 10:41:34.000000000 +0200
@@ -10,11 +10,11 @@
apply plugin: 'com.android.library'
android {
- compileSdkVersion 24
- buildToolsVersion "24.0.1"
+ compileSdkVersion 28
+ buildToolsVersion "28.0.1"
defaultConfig {
minSdkVersion 16
- targetSdkVersion 24
+ targetSdkVersion 28
versionCode 1
versionName "0.1"
externalNativeBuild {
Can you instead make a pull request in github? It would be easier and more traceable than patching.
@lyubo I agree but I am unsure if this is the correct way of fixing this. If you think it is, I will create a PR, np.
fyi @peterkuiper @lyubo what I discovered was that the build somehow did not unpack precompiled.tgz
so there was no libsodium
directory - not sure why this was happening but I unpacked it and problem was solved.
also I am forcing subprojects to use 28/28.0.3, so did not need to change libsodium gradle
@mutablestudio I'm experiencing the same thing. Sometimes the postinstall
does not run (package.json). How do you force subprojects to use 28/28.0.3? Maybe you can share your changes with us.
to force subprojects, @peterkuiper in your root build.gradle
(not the app gradle):
ext {
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
}
// Force sub libs to use the compile sdk & build tools version
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
We are using expo ejected, have been using react-native-sodium without issue until we made compile and target sdk 28. Can't seem to get past this error in both debug and release builds.
package.json:
AS error log: