Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade react-native to 0.75.3 #21268

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ nix-purge: ##@nix Completely remove Nix setup, including /nix directory
nix/scripts/purge.sh

nix-update-gradle: export TARGET := gradle
nix-update-gradle: export ORG_GRADLE_PROJECT_hermesEnabled := false
nix-update-gradle: export ORG_GRADLE_PROJECT_universalApk := false
nix-update-gradle: ##@nix Update maven nix expressions based on current gradle setup
nix/deps/gradle/generate.sh

Expand Down Expand Up @@ -476,6 +478,10 @@ android-install: export BUILD_TYPE ?= release
android-install: ##@other Install APK on device using adb
adb install result/app-$(BUILD_TYPE).apk

generate-autolink-android: export TARGET := clojure
generate-autolink-android: ##@other Generate autolinking.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if it's required for Android why is it not a dependency in the Makefile?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only need this in Jenkins file for Android build step, and this step runs one of the npm libraries react-native-config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually making this a dependency for android would be a good idea. I will try it out locally.

@scripts/generate_autolink_android.sh

_list: SHELL := /bin/sh
_list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
Expand Down
7 changes: 4 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]

/* Autolinking */
autolinkLibrariesWithApp()
}

/**
Expand Down Expand Up @@ -297,7 +300,7 @@ dependencies {
implementation("com.facebook.fresco:fresco:2.5.0")
implementation("com.facebook.fresco:animated-gif:2.5.0")
implementation("com.squareup.okhttp3:okhttp-tls:4.11.0")
implementation("com.google.prefab:cli:2.0.0")
implementation("com.google.prefab:cli:2.1.0")
implementation("com.android.tools.build:aapt2:8.1.1-10154469")
}

Expand Down Expand Up @@ -333,5 +336,3 @@ task hemroidBuild(type: Exec) {
}

preBuild.dependsOn hemroidBuild

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
2 changes: 2 additions & 0 deletions android/app/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ LOCAL_MODULE := status-logs
LOCAL_SRC_FILES := Log.c

LOCAL_CPPFLAGS := -std=c++11 -fexceptions -I$(LOCAL_PATH)/include
# Fix for : ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
LOCAL_CFLAGS := '-Wno-error=implicit-function-declaration'
LOCAL_LDFLAGS := -llog

include $(BUILD_SHARED_LIBRARY)
7 changes: 6 additions & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@
<!-- Remove licensing permission since we don't license our app and it blocks F-Droid submissions. -->
<uses-permission tools:node="remove" android:name="com.android.vending.CHECK_LICENSE"/>

<application tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" android:usesCleartextTraffic="true" />
<application
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning"
android:usesCleartextTraffic="true"
tools:replace="android:appComponentFactory"
android:appComponentFactory="androidx.core.app.CoreComponentFactory" />
</manifest>
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
android:largeHeap="true"
android:usesCleartextTraffic="true"
android:extractNativeLibs="true"
android:requestLegacyExternalStorage="true">
android:requestLegacyExternalStorage="true"
android:supportsRtl="true">
<!-- After upgrading Android Gradle Plugin to 4.2.0 and above we must get rid of `extractNativeLibs="true"`
and use`useLegacyPackaging` flag in our app's `build.gradle`-->
<meta-data android:name="commitHash" android:value="${commitHash}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.JSIModulePackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint
import com.facebook.react.modules.network.OkHttpClientProvider
import com.reactnativenavigation.NavigationApplication
Expand Down
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ ext {
kotlinVersion = project.kotlinPluginVersion
kotlinPluginVersion = project.kotlinPluginVersion
kotlinToolsVersion = project.kotlinPluginVersion
ndkVersion = "25.2.9519653"
// This version must match ndkVersion version inside nix/pkgs/android-sdk/compose.nix
ndkVersion = "26.1.10909125"
}

buildscript {
Expand Down
5 changes: 2 additions & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ targetSdkVersion=34
buildToolsVersion=34.0.0
supportLibVersion=28.0.0
# This should match version from nix/pkgs/aapt2/default.nix
gradlePluginVersion=7.4.2
kotlinPluginVersion=1.9.0
gradlePluginVersion=8.5.0
kotlinPluginVersion=1.9.24

android.useAndroidX=true
android.enableJetifier=true
Expand All @@ -54,7 +54,6 @@ commitHash=unknown
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false

# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
# Disabled for debug builds to avoid 'maximum call stack exceeded' errors.
Expand Down
5 changes: 3 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
pluginManagement {
includeBuild("../node_modules/@react-native/gradle-plugin")
include ':react-native-share'
project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android')
repositories {
mavenLocal() // Let's prioritize local Maven repos so that Nix can provide them offline
gradlePluginPortal()
}
}

plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'StatusIm'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':react-native-nfc-manager'
project(':react-native-nfc-manager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-nfc-manager/android')
include ':app'
Expand Down
1 change: 1 addition & 0 deletions ci/Jenkinsfile.android
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pipeline {
script {
utils.symlinkEnv()
println("Build Number: ${utils.genBuildNumber()}")
sh 'make generate-autolink-android'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing this here? It seems kinda awkward do do this as part of Makefile if it's always necessary for Android.

Why can't this be part of the Gradle build process for example? Is there ever a case where it don't need to run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do this in 2 places, here for PR builds and inside scripts/build-android.sh for Debug builds which are run when we do make run-android.

The autolinking json file was introduced originally as a gradle build step by react-native team.
However the issue with that is this autolinking stuff runs npx @react-native-community/cli config at runtime and we can't run this inside our nix derivation since that runs in a sandbox environment.

Hence I have made these changes.
I have also patched out this behaviour from react-native to make sure it works well with our build process.

The second question about is there ever a case where it doesn't need to be run, well we only need the autolinking json file right before we have to do an android build. Otherwise we don't need it.

}
}
}
Expand Down
1 change: 1 addition & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ abstract_target 'Status' do
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false,
# :ccache_enabled => true
)
# some of libs wouldn't be build for x86_64 otherwise and that is
# necessary for ios simulators
Expand Down
Loading