Skip to content

Commit

Permalink
fix: Fix Android build/update packages (#198)
Browse files Browse the repository at this point in the history
* Update the thingy

* Update to latest RN

* Update Android build setup

* More Android Fixes

* Remove MainApplication.java manual import of package
  • Loading branch information
ospfranco committed Nov 28, 2023
1 parent 2668491 commit 8d4bbcd
Show file tree
Hide file tree
Showing 21 changed files with 2,148 additions and 2,528 deletions.
24 changes: 17 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath("com.android.tools.build:gradle:7.2.2")
}
}

Expand All @@ -47,6 +47,13 @@ def reactNativeArchitectures() {
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def resolveBuildType() {
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()

return tskReqStr.contains('Release') ? 'release' : 'debug'
}

def reactProperties = new Properties()
file("$nodeModules/react-native/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }

Expand Down Expand Up @@ -83,6 +90,7 @@ android {
}

packagingOptions {
doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
excludes = [
"**/libc++_shared.so",
"**/libfbjni.so",
Expand All @@ -91,9 +99,12 @@ android {
"**/libreact_nativemodule_core.so",
"**/libturbomodulejsijni.so",
"**/MANIFEST.MF",
""
]
doNotStrip '**/*.so'
// Should prevent clashes with other libraries that use OpenSSL
pickFirst '**/x86/libcrypto.so'
pickFirst '**/x86_64/libcrypto.so'
pickFirst '**/armeabi-v7a/libcrypto.so'
pickFirst '**/arm64-v8a/libcrypto.so'
}

buildTypes {
Expand Down Expand Up @@ -130,9 +141,8 @@ repositories {
}

dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-android:+'
// https://mvnrepository.com/artifact/com.android.ndk.thirdparty/openssl
implementation 'com.android.ndk.thirdparty:openssl:1.1.1l-beta-1'

implementation "com.facebook.react:react-android:"
implementation "com.facebook.react:hermes-android:"
implementation 'com.android.ndk.thirdparty:openssl:1.1.1q-beta-1'
}
4 changes: 3 additions & 1 deletion example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"prefer_split_fsevents_watcher": true
}
2 changes: 0 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ dependencies {
} else {
implementation jscFlavor
}

implementation project(':reactnativequickcrypto')
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public boolean getUseDeveloperSupport() {
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new QuickCryptoPackage());
return packages;
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
}
}
6 changes: 2 additions & 4 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
rootProject.name = 'QuickCryptoExample'

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')

include ':reactnativequickcrypto'
project(':reactnativequickcrypto').projectDir = new File(rootProject.projectDir, '../../android')
includeBuild('../node_modules/@react-native/gradle-plugin')
3 changes: 2 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const crypto = require('crypto');
const quickCrypto = require('react-native-quick-crypto');
// const quickCrypto = require('react-native-quick-crypto');
import quickCrypto from 'react-native-quick-crypto';

crypto.publicEncrypt = quickCrypto.publicEncrypt;
crypto.privateDecrypt = quickCrypto.privateDecrypt;
Expand Down
26 changes: 2 additions & 24 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
platform :ios, min_ios_version_supported
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
Expand All @@ -29,32 +18,21 @@ target 'QuickCryptoExample' do

use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

pod 'react-native-quick-crypto', :path => '../..'

target 'QuickCryptoExampleTests' do
inherit! :complete
# Pods for testing
end

post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
config[:reactNativePath],
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
Expand Down
Loading

0 comments on commit 8d4bbcd

Please sign in to comment.