Skip to content

Commit e66de2b

Browse files
andrepimentametamaskbotsethkfmantommasinileotm
authored
chore: Upgrade React Native to 0.76.6 (#13771)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> # **Description** This PR upgrades React Native from 0.72.15 to 0.76.6 and Expo from ^49.0.0 to ~52.0.27. # Changes In general, we tried to change the code as less as possible to make it work with the new React Native and Expo versions. ## There are 8 main changes: ### 1. React Native/Expo upgrade guide I followed the guide: https://docs.expo.dev/bare/upgrade/?fromSdk=49&toSdk=52#packagejson to update to the new version of both React Native and Expo. Check the guide to see the files I needed to update. It seemed like a more complete guide instead of the React Native one and it made more sense to me to follow this one since we are using Expo. This is included in the first 2 commits. These commits also include other changes to ensure Android and iOS build and run locally. #### Changes worth mentioning ##### Flipper Removal All the changes related to Flipper are due to the removal of Flipper, long awaited change! ##### iPhone Deployment Target The IPHONEOS_DEPLOYMENT_TARGET was updated from 13.0 to 15.1 ##### Android NDK Version The NDK version was updated from 24.0.8215888 to 26.1.10909125 (devs should install it within Android Studio) ### 2. [RN_ELEMENT].propTypes deprecated [RN_ELEMENT].propTypes was deprecated by (RN 0.74)[https://reactnative.dev/blog/2024/04/22/release-0.74#removal-of-deprecated-proptypes]. There are components and patches applied to change the use of propTypes to be compatible with the new React Native version. Generally we used the propTypes `deprecated-react-native-prop-types` like ViewPropTypes and TextPropTypes to fix this without changing too much the code. For example: `app/components/Base/Keypad/components.js` ### 3. *.test.tsx files updated There are some test files that were updated to fix some E2E and unit tests errors. For example: `app/components/UI/AccountApproval/index.test.tsx` ### 4. *.test.tsx.snap files updated There are some snapshot files that needed to be updated to be compatible with the new React Native version components. For example: `app/components/UI/AccountApproval/__snapshots__/index.test.tsx.snap` ### 5. Typescript linting fixes There are some files where we had to fix typescript linting errors. For example: `app/component-library/components/Pickers/PickerAccount/PickerAccount.tsx` ### 6. Icons names updated There are some icons names that were updated to be compatible with the new Expo icons. For example: `app/components/Base/DetailsModal.js` ### 7. Libs updates - react, react-native, expo, @react-native/metro-config: Updated to correspond to the RN upgrade - deprecated-react-native-prop-types: I had to use this lib to replace instances like Text.propTypes.style because RN deprecated all [Element].propTypes - react-native-scrollable-tab-view: This library is not maintained anymore, we should consider moving to another library, in the meanwhile I have updated to the latest commit there and had to do a patch on top (explained below). - flipper related libraries: Flipper is finally removed! - The rest of the libraries updates were due to incompatibilities with the new RN upgrade ### 8. Patches - Majority of patches were to fix the propTypes deprecation. - `react-native-scrollable-tab-view`: A lot of incompatibilities with the new RN version. The changes basically made it compatible without having to move to another lib (although this should be a task for the future). - Rest of patches: Basically making libraries work with the new RN ### All other changes All the other changes were either because of the Guide mentioned above or details here and there that had to be implemented in order for the app to build/run with the new upgrade. Happy to explain any change that I haven't mentioned here :) <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: metamaskbot <[email protected]> Co-authored-by: sethkfman <[email protected]> Co-authored-by: tommasini <[email protected]> Co-authored-by: tommasini <[email protected]> Co-authored-by: LeoTM <[email protected]>
1 parent 6c1aecc commit e66de2b

File tree

378 files changed

+22018
-20334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

378 files changed

+22018
-20334
lines changed

.depcheckrc.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,26 @@ ignores:
7979
- 'url'
8080
- 'vm-browserify'
8181
- 'react-native-cli'
82+
- 'babel-plugin-module-resolver'
8283

8384
## Missing dependencies to investigate
8485
- '@react-navigation/core'
8586
- 'app'
8687
- 'i18n-js'
8788
- 'images'
88-
89+
8990
## Expo
9091
- '@config-plugins/detox'
9192
- 'cross-spawn'
9293
- 'expo-build-properties'
9394
- 'expo-dev-client'
94-
95+
96+
## react native
97+
- '@react-native-community/cli'
98+
- '@react-native-community/cli-platform-android'
99+
- '@react-native-community/cli-platform-ios'
100+
- '@react-native-community/cli-server-api'
101+
- '@react-native/typescript-config'
102+
- 'react-native-pager-view'
103+
# this dependency can probably be removed, needs investigation
104+
- '@types/react-test-renderer'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ android/app/.project
3838
android/app/bin/
3939
android/app/gradle*
4040
android/app/_build*
41+
.cxx/
4142

4243
# if we ever want to add google services
4344
android/app/google-services.json
@@ -134,6 +135,7 @@ android/app/src/main/assets/modules.json
134135
.expo
135136
dist/
136137
web-build/
138+
expo-env.d.ts
137139

138140
# CICD
139141
github-tools/

.iyarc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# https://github.com/advisories/GHSA-c76h-2ccp-4975 This is temporarily ignored, will be fixed by updating yarn to v3 in this PR: https://github.com/MetaMask/metamask-mobile/pull/14477
2+
GHSA-c76h-2ccp-4975

android/app/build.gradle

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "org.jetbrains.kotlin.android"
23
apply plugin: "com.facebook.react"
34
apply plugin: "io.sentry.android.gradle"
45
apply plugin: 'com.google.gms.google-services'
6+
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
57

68
/**
79
* This is the configuration block to customize your React Native Android app.
@@ -49,9 +51,15 @@ react {
4951
// hermesFlags = ["-O", "-output-source-map"]
5052
//
5153
// Added by install-expo-modules
52-
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
53-
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
54+
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
55+
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
56+
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
57+
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
58+
cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
5459
bundleCommand = "export:embed"
60+
61+
/* Autolinking */
62+
autolinkLibrariesWithApp()
5563
}
5664

5765
// Override default React Native to generate source maps for Hermes
@@ -170,7 +178,8 @@ def ndkPath() {
170178
android {
171179
ndkVersion rootProject.ext.ndkVersion
172180

173-
compileSdkVersion rootProject.ext.compileSdkVersion
181+
buildToolsVersion rootProject.ext.buildToolsVersion
182+
compileSdk rootProject.ext.compileSdkVersion
174183

175184
namespace"io.metamask"
176185

@@ -179,7 +188,7 @@ android {
179188
minSdkVersion rootProject.ext.minSdkVersion
180189
targetSdkVersion rootProject.ext.targetSdkVersion
181190
versionName "7.44.0"
182-
versionCode 1707
191+
versionCode 1773
183192
testBuildType System.getProperty('testBuildType', 'debug')
184193
missingDimensionStrategy 'react-native-camera', 'general'
185194
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -197,8 +206,18 @@ android {
197206
pickFirst 'lib/armeabi-v7a/libcrypto.so'
198207
pickFirst 'lib/x86/libcrypto.so'
199208
pickFirst 'lib/x86_64/libcrypto.so'
209+
jniLibs {
210+
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
211+
}
212+
exclude 'META-INF/AL2.0'
213+
exclude 'META-INF/LGPL2.1'
214+
exclude 'mockito-extensions/org.mockito.plugins.MockMaker'
200215
}
201216

217+
androidResources {
218+
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
219+
}
220+
202221
signingConfigs {
203222
release {
204223
storeFile file('../keystores/release.keystore')
@@ -235,6 +254,8 @@ android {
235254
manifestPlaceholders.isDebug = false
236255
minifyEnabled enableProguardInReleaseBuilds
237256
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro", "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules.pro"
257+
crunchPngs (findProperty('android.enablePngCrunchInReleaseBuilds')?.toBoolean() ?: true)
258+
testProguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro", "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules.pro"
238259
}
239260
}
240261

@@ -271,6 +292,10 @@ android {
271292
// Used to point to dev environment API for ramp
272293
it.buildConfigField 'String', 'IS_RAMP_DEV', "\"$System.env.RAMP_DEV_BUILD\""
273294
}
295+
296+
buildFeatures {
297+
buildConfig = true
298+
}
274299
}
275300

276301
dependencies {
@@ -282,12 +307,7 @@ dependencies {
282307
androidTestImplementation 'org.mockito:mockito-android:4.2.0'
283308
androidTestImplementation 'androidx.test:core:1.5.0'
284309
androidTestImplementation 'androidx.test:core-ktx:1.5.0'
285-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
286-
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
287-
exclude group:'com.squareup.okhttp3', module:'okhttp'
288-
}
289310

290-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
291311
if (hermesEnabled.toBoolean()) {
292312
implementation("com.facebook.react:hermes-android")
293313
} else {
@@ -297,6 +317,15 @@ dependencies {
297317
exclude module: "protobuf-lite"
298318
}
299319
androidTestImplementation ('androidx.test.espresso:espresso-contrib:3.4.0')
300-
}
301320

302-
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
321+
// Add these dependencies for androidTest
322+
androidTestImplementation "com.google.guava:guava:31.1-android"
323+
androidTestImplementation "org.ow2.asm:asm:9.4"
324+
androidTestImplementation "net.java.dev.jna:jna:5.12.1"
325+
androidTestImplementation "net.java.dev.jna:jna-platform:5.12.1"
326+
androidTestImplementation "org.opentest4j:opentest4j:1.2.0"
327+
328+
// Make sure you have the proper Mockito dependencies
329+
androidTestImplementation "org.mockito:mockito-core:4.8.0"
330+
androidTestImplementation "org.mockito:mockito-inline:4.8.0"
331+
}

android/app/proguard-rules.pro

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,18 @@
4848
-keep class kotlin.** { *; }
4949

5050
-keep class kotlin.Metadata { *; }
51+
52+
-dontwarn kotlinx.serialization.SerialName
53+
-dontwarn kotlinx.serialization.Serializable
54+
55+
# Ignore missing Java desktop classes referenced by JNA
56+
-dontwarn java.awt.**
57+
-dontwarn javax.swing.**
58+
-dontwarn java.lang.instrument.**
59+
-dontwarn sun.misc.**
60+
-dontwarn org.mockito.**
61+
-dontwarn edu.umd.cs.findbugs.**
62+
-dontwarn com.huawei.hms.ads.**
63+
-dontwarn com.google.common.util.concurrent.**
64+
-dontwarn org.objectweb.asm.**
65+
-dontwarn net.bytebuddy.**

android/app/src/androidTest/java/com/metamask/nativeModules/RNTarTest/RNTarTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class RNTarTest {
3636

3737
@Before
3838
public void setUp() {
39-
reactContext = new ReactApplicationContext(ApplicationProvider.getApplicationContext());
39+
reactContext = mock(ReactApplicationContext.class);
4040
tar = new RNTar(reactContext);
4141
promise = mock(Promise.class);
4242
}

android/app/src/debug/java/io/metamask/ReactNativeFlipper.java

Lines changed: 0 additions & 75 deletions
This file was deleted.

android/app/src/main/java/io/metamask/MainActivity.java

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)