From f60aecd13546a6841df6d28dda2e4c6be287113c Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Tue, 4 Apr 2023 16:54:34 +0200 Subject: [PATCH 01/24] WIP! Upgrade to 0.72 sdk, android sample --- RNSentry.podspec | 2 +- package.json | 2 +- sample-new-architecture/.eslintrc.js | 2 +- .../android/app/build.gradle | 47 +- .../samplenewarchitecture/MainActivity.java | 4 +- sample-new-architecture/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- sample-new-architecture/android/gradlew | 18 +- sample-new-architecture/android/gradlew.bat | 15 +- .../android/settings.gradle | 2 +- sample-new-architecture/ios/Podfile | 3 + sample-new-architecture/package.json | 10 +- .../src/Screens/HomeScreen.tsx | 10 + sample-new-architecture/yarn.lock | 1757 ++++++++--------- yarn.lock | 1368 ++++--------- 15 files changed, 1211 insertions(+), 2034 deletions(-) diff --git a/RNSentry.podspec b/RNSentry.podspec index 67eee6aae4..9062054002 100644 --- a/RNSentry.podspec +++ b/RNSentry.podspec @@ -19,7 +19,7 @@ Pod::Spec.new do |s| s.preserve_paths = '*.js' s.dependency 'React-Core' - s.dependency 'Sentry/HybridSDK', '8.3.3' + # s.dependency 'Sentry/HybridSDK', '8.3.3' s.source_files = 'ios/**/*.{h,mm}' s.public_header_files = 'ios/RNSentry.h' diff --git a/package.json b/package.json index b582056baf..6afa6e18f4 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "jest-environment-jsdom": "^29.4.1", "prettier": "^2.0.5", "react": "18.2.0", - "react-native": "0.71.0", + "react-native": "0.72.0-rc.0", "replace-in-file": "^6.0.0", "rimraf": "^4.1.1", "ts-jest": "^29.0.5", diff --git a/sample-new-architecture/.eslintrc.js b/sample-new-architecture/.eslintrc.js index 3d4d370fc5..b84c804e8d 100644 --- a/sample-new-architecture/.eslintrc.js +++ b/sample-new-architecture/.eslintrc.js @@ -1,6 +1,6 @@ module.exports = { root: true, - extends: '@react-native-community', + extends: '@react-native', parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint'], overrides: [ diff --git a/sample-new-architecture/android/app/build.gradle b/sample-new-architecture/android/app/build.gradle index 0109dc8670..2edda8e7dc 100644 --- a/sample-new-architecture/android/app/build.gradle +++ b/sample-new-architecture/android/app/build.gradle @@ -2,8 +2,6 @@ apply plugin: "com.android.application" apply plugin: "com.facebook.react" apply plugin: "io.sentry.android.gradle" -import com.android.build.OutputFile - sentry { // Disables or enables the automatic configuration of Native Symbols // for Sentry. This executes sentry-cli automatically so @@ -24,8 +22,8 @@ react { // root = file("../") // The folder where the react-native NPM package is. Default is ../node_modules/react-native // reactNativeDir = file("../node_modules/react-native") - // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen - // codegenDir = file("../node_modules/react-native-codegen") + // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen + // codegenDir = file("../node_modules/@react-native/codegen") // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js // cliFile = file("../node_modules/react-native/cli.js") /* Variants */ @@ -71,14 +69,6 @@ project.ext.sentryCli = [ apply from: "../../../sentry.gradle" -/** - * Set this to true to create four separate APKs instead of one, - * one for each native architecture. This is useful if you don't - * use App Bundles (https://developer.android.com/guide/app-bundle/) - * and want to have separate APKs to upload to the Play Store. - */ -def enableSeparateBuildPerCPUArchitecture = false - /** * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ @@ -97,14 +87,6 @@ def enableProguardInReleaseBuilds = true */ def jscFlavor = 'org.webkit:android-jsc:+' -/** - * Architectures to build native code for. - */ -def reactNativeArchitectures() { - def value = project.getProperties().get("reactNativeArchitectures") - return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] -} - android { ndkVersion rootProject.ext.ndkVersion @@ -119,14 +101,6 @@ android { versionName "1.0" } - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include (*reactNativeArchitectures()) - } - } signingConfigs { debug { storeFile file('debug.keystore') @@ -148,23 +122,6 @@ android { } } - // applicationVariants are e.g. debug, release - applicationVariants.all { variant -> - variant.outputs.each { output -> - // For each separate APK per architecture, set a unique version code as described here: - // https://developer.android.com/studio/build/configure-apk-splits.html - // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. - def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] - def abi = output.getFilter(OutputFile.ABI) - if (abi != null) { // null for the universal-debug, universal-release variants - output.versionCodeOverride = - defaultConfig.versionCode * 1000 + versionCodes.get(abi) - } - - } - } - - } dependencies { diff --git a/sample-new-architecture/android/app/src/main/java/com/samplenewarchitecture/MainActivity.java b/sample-new-architecture/android/app/src/main/java/com/samplenewarchitecture/MainActivity.java index 906ed3cd6a..bce35655e4 100644 --- a/sample-new-architecture/android/app/src/main/java/com/samplenewarchitecture/MainActivity.java +++ b/sample-new-architecture/android/app/src/main/java/com/samplenewarchitecture/MainActivity.java @@ -28,9 +28,7 @@ protected ReactActivityDelegate createReactActivityDelegate() { this, getMainComponentName(), // If you opted-in for the New Architecture, we enable the Fabric Renderer. - DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled - // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18). - DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled + DefaultNewArchitectureEntryPoint.getFabricEnabled() ); } diff --git a/sample-new-architecture/android/build.gradle b/sample-new-architecture/android/build.gradle index 961c7a4155..6c03c7d6c8 100644 --- a/sample-new-architecture/android/build.gradle +++ b/sample-new-architecture/android/build.gradle @@ -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") classpath("io.sentry:sentry-android-gradle-plugin:3.4.2") } diff --git a/sample-new-architecture/android/gradle/wrapper/gradle-wrapper.properties b/sample-new-architecture/android/gradle/wrapper/gradle-wrapper.properties index 8fad3f5a98..6ec1567a0f 100644 --- a/sample-new-architecture/android/gradle/wrapper/gradle-wrapper.properties +++ b/sample-new-architecture/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/sample-new-architecture/android/gradlew b/sample-new-architecture/android/gradlew index 1b6c787337..79a61d421c 100755 --- a/sample-new-architecture/android/gradlew +++ b/sample-new-architecture/android/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/sample-new-architecture/android/gradlew.bat b/sample-new-architecture/android/gradlew.bat index ac1b06f938..6689b85bee 100644 --- a/sample-new-architecture/android/gradlew.bat +++ b/sample-new-architecture/android/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/sample-new-architecture/android/settings.gradle b/sample-new-architecture/android/settings.gradle index ad4844d2a8..79fde45838 100644 --- a/sample-new-architecture/android/settings.gradle +++ b/sample-new-architecture/android/settings.gradle @@ -1,4 +1,4 @@ rootProject.name = 'sampleNewArchitecture' 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') +includeBuild('../node_modules/@react-native/gradle-plugin') diff --git a/sample-new-architecture/ios/Podfile b/sample-new-architecture/ios/Podfile index f4697edb85..4c7f007564 100644 --- a/sample-new-architecture/ios/Podfile +++ b/sample-new-architecture/ios/Podfile @@ -54,6 +54,9 @@ target 'sampleNewArchitecture' do # Pods for testing end + pod 'Sentry/HybridSDK', :path => '../../../sentry-cocoa' + pod 'SentryPrivate', :path => '../../../sentry-cocoa/SentryPrivate.podspec' + post_install do |installer| react_native_post_install( installer, diff --git a/sample-new-architecture/package.json b/sample-new-architecture/package.json index 6bd8ef7ac3..d29f481355 100644 --- a/sample-new-architecture/package.json +++ b/sample-new-architecture/package.json @@ -15,10 +15,11 @@ }, "dependencies": { "@react-native-community/cli-platform-android": "^10.1.3", + "@react-native/eslint-config": "^0.73.0", "@react-navigation/native": "^6.1.2", "@react-navigation/stack": "^6.3.11", "react": "18.2.0", - "react-native": "0.71.1", + "react-native": "0.72.0-rc.0", "react-native-gesture-handler": "^2.9.0", "react-native-safe-area-context": "^4.5.0", "react-native-screens": "^3.19.0", @@ -26,10 +27,9 @@ "redux": "^4.2.0" }, "devDependencies": { - "@babel/core": "^7.20.0", - "@babel/preset-env": "^7.20.0", + "@babel/core": "^7.21.4", + "@babel/preset-env": "^7.21.4", "@babel/runtime": "^7.20.0", - "@react-native-community/eslint-config": "^3.0.0", "@tsconfig/react-native": "^2.0.2", "@types/jest": "^29.2.1", "@types/react-test-renderer": "^18.0.0", @@ -41,7 +41,7 @@ "eslint-plugin-ft-flow": "^2.0.3", "eslint-plugin-jest": "^27.2.1", "jest": "^29.2.1", - "metro-react-native-babel-preset": "^0.73.7", + "metro-react-native-babel-preset": "^0.76.0", "prettier": "^2.4.1", "react-test-renderer": "18.2.0", "typescript": "4.8.4" diff --git a/sample-new-architecture/src/Screens/HomeScreen.tsx b/sample-new-architecture/src/Screens/HomeScreen.tsx index b23cbfb401..228053223f 100644 --- a/sample-new-architecture/src/Screens/HomeScreen.tsx +++ b/sample-new-architecture/src/Screens/HomeScreen.tsx @@ -156,6 +156,16 @@ const HomeScreen = (props: Props) => { }); }} /> +