Skip to content

Commit d62aecb

Browse files
authored
Merge pull request #59 from numandev1/fix/expo
fix: libcrypto.so issue for release android
2 parents 98af2e2 + cdbf83d commit d62aecb

File tree

13 files changed

+635
-639
lines changed

13 files changed

+635
-639
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ android/keystores/debug.keystore
6363
lib/
6464
**prebuild.log
6565
example/ios/tmp.xcconfig
66+
67+
src/type.ts
68+
cpp/crypto.cpp
69+
android/src/main/java/com/reactnativekeysjsi/PrivateKey.java

README.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,14 @@ import static com.reactnativekeysjsi.KeysModule.getSecureFor;
424424
String secureValue = getSecureFor("BRANCH_KEY"); // key_test_omQ7YYKiq57vOqEJsdcsdfeEsiWkwxE
425425
```
426426

427+
#### Android troubleshoot
428+
429+
- [Problems with Proguard](#problems-with-proguard)
430+
- [2 files found with path '\*\*/libcrypto.so](#2-files-found-with-path-libcryptoso)
431+
- [Advanced Android Setup for applicationIdSuffix](#advanced-android-setup-1)
432+
433+
````
434+
427435
### iOS
428436
429437
#### Public Keys
@@ -439,7 +447,7 @@ NSString *value = [Keys publicFor:@"API_URL"]; // https://example.com
439447
440448
// or just fetch all keys
441449
NSDictionary *allKeys = [Keys public_keys];
442-
```
450+
````
443451

444452
#### Secure Keys
445453

@@ -544,6 +552,22 @@ If using Dexguard, the shrinking phase will remove resources it thinks are unuse
544552

545553
-keepresources string/build_config_package
546554

555+
### 2 files found with path '\*\*/libcrypto.so
556+
557+
if you face `2 files found with path '**/libcrypto.so'` then
558+
inside android/app/build.gradle just add this:
559+
560+
```
561+
android {
562+
...
563+
packagingOptions {
564+
pickFirst 'lib/x86/libcrypto.so'
565+
pickFirst 'lib/x86_64/libcrypto.so'
566+
pickFirst 'lib/armeabi-v7a/libcrypto.so'
567+
pickFirst 'lib/arm64-v8a/libcrypto.so'
568+
}
569+
}
570+
547571
### Using node with nvm, fnm or notion
548572
549573
Build failure in Xcode looks something like:
@@ -553,35 +577,41 @@ Build failure in Xcode looks something like:
553577
Change the **Pre-actions script** scripts in Xcode to:
554578
555579
```
580+
556581
# Setup nvm and set node
582+
557583
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
558584

559-
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
585+
if [[-s "$HOME/.nvm/nvm.sh"]]; then
560586
. "$HOME/.nvm/nvm.sh"
561587
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
562588
. "$(brew --prefix nvm)/nvm.sh"
563589
fi
564590

565591
# Set up the nodenv node version manager if present
566-
if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
592+
593+
if [[-x "$HOME/.nodenv/bin/nodenv"]]; then
567594
eval "$("$HOME/.nodenv/bin/nodenv" init -)"
568595
fi
569596

570597
# Set up the fnm node version manager if present
571-
if [[ -s "$HOME/.fnm/fnm" ]]; then
572-
eval "`$HOME/.fnm/fnm env --multi`"
598+
599+
if [[-s "$HOME/.fnm/fnm"]]; then
600+
eval "`$HOME/.fnm/fnm env --multi`"
573601
fi
574602

575603
# Trying notion
604+
576605
if [ -z "$NODE_BINARY" ]; then
577-
if [[ -s "$HOME/.notion/bin/node" ]]; then
606+
if [[-s "$HOME/.notion/bin/node"]]; then
578607
export NODE_BINARY="$HOME/.notion/bin/node"
579608
fi
580609
fi
581610

582611
[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"
583612

584613
$NODE_BINARY "${SRCROOT}/../node_modules/react-native-keys/keysIOS.js"
614+
585615
```
586616
587617
# Alternative Package
@@ -597,3 +627,4 @@ If you are using the library in one of your projects, consider supporting it wit
597627
## Meta
598628
599629
Created by [Numan.dev](https://numan.dev/).
630+
```

android/build.gradle

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,31 @@ android {
150150
path "CMakeLists.txt"
151151
}
152152
}
153-
packagingOptions {
154-
excludes = ['**/libc++_shared.so',
155-
'**/libfbjni.so',
156-
'**/libreactnativejni.so',
157-
'**/libjsi.so',
158-
'**/libreact_nativemodule_core.so',
159-
'**/libturbomodulejsijni.so',
160-
'**/libcrypto.so'
153+
154+
packagingOptions {
155+
excludes = [
156+
"**/libc++_shared.so",
157+
"**/libfbjni.so",
158+
"**/libreactnativejni.so",
159+
"**/libjsi.so",
160+
"**/libreact_nativemodule_core.so",
161+
"**/libturbomodulejsijni.so",
162+
"**/MANIFEST.MF",
163+
""
161164
]
165+
doNotStrip '**/*.so'
162166
}
167+
163168
buildTypes {
169+
debug {
170+
packagingOptions {
171+
doNotStrip '**/*.so'
172+
}
173+
minifyEnabled false
174+
debuggable true
175+
jniDebuggable true
176+
renderscriptDebuggable true
177+
}
164178
release {
165179
minifyEnabled false
166180
}

example/android/app/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ project.ext.keyFiles = [
77
staging: "keys.staging.json"
88
]
99

10-
apply from: project(':reactNativeKeys').projectDir.getPath() + "/RNKeys.gradle"
10+
apply from: project(':react-native-keys').projectDir.getPath() + "/RNKeys.gradle"
1111

1212
/**
1313
* This is the configuration block to customize your React Native Android app.
@@ -102,6 +102,12 @@ android {
102102
applicationIdSuffix ""
103103
}
104104
}
105+
packagingOptions {
106+
pickFirst 'lib/x86/libcrypto.so'
107+
pickFirst 'lib/x86_64/libcrypto.so'
108+
pickFirst 'lib/armeabi-v7a/libcrypto.so'
109+
pickFirst 'lib/arm64-v8a/libcrypto.so'
110+
}
105111
signingConfigs {
106112
debug {
107113
storeFile file('debug.keystore')
@@ -139,7 +145,6 @@ dependencies {
139145
} else {
140146
implementation jscFlavor
141147
}
142-
implementation project(':reactNativeKeys')
143148
}
144149

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

example/android/settings.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@ rootProject.name = 'KeysExample'
22
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
33
include ':app'
44
includeBuild('../node_modules/@react-native/gradle-plugin')
5-
include ':reactNativeKeys'
6-
project(':reactNativeKeys').projectDir = new File(rootProject.projectDir, '../../android')

exampleExpo/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInRelea
6666
project.ext.IS_EXAMPLE = true;
6767
project.ext.DEFAULT_FILE_NAME = "keys.production.json"
6868
apply from: project(':react-native-keys').projectDir.getPath() + "/RNKeys.gradle"
69-
69+
7070

7171
/**
7272
* The preferred build flavor of JavaScriptCore (JSC)

0 commit comments

Comments
 (0)