react-native-community / upgrade-support

A central community-backed place to request and give help when upgrading your app.
MIT License
251 stars 2 forks source link

Upgrade 0.70.6 to 0.71.12 "Operation is not supported for read-only collection" #241

Closed alexborton closed 11 months ago

alexborton commented 11 months ago

Environment

System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 107.78 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.16.1 - ~/.nvm/versions/node/v18.16.1/bin/node
    Yarn: 3.2.4 - ~/.nvm/versions/node/v18.16.1/bin/yarn
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.1/bin/npm
    Watchman: 2023.01.09.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 23, 28, 29, 30, 31, 33
      Build Tools: 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 33.0.0
      System Images: android-28 | ARM 64 v8a, android-28 | Intel x86 Atom_64, android-28 | Google ARM64-V8a Play ARM 64 v8a, android-29 | ARM 64 v8a, android-31 | ARM 64 v8a, android-31 | Google Play ARM 64 v8a, android-33 | Google APIs ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2022.2 AI-222.4459.24.2221.9862592
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.16.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.12 => 0.71.12 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Things I’ve done to figure out my issue

switching the offending line to a boolean gets me onto the next instance of said line;

def enableHermes = project.ext.react.get("enableHermes", false); -> def enableHermes = true;

Upgrading version

0.71.12

Description

Gradle fails on the following line;

def enableHermes = project.ext.react.get("enableHermes", false);

citing the following;

1: Task failed with an exception.
-----------
* Where:
Build file '[path]/android/app/build.gradle' line: 93

* What went wrong:
A problem occurred evaluating project ':app'.
> Operation is not supported for read-only collection

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

I am upgrading from RN 0.70.6 and have some Kotlin setup in my gradle, too that might be noteworthy;

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 26
        compileSdkVersion = 33
        targetSdkVersion = 33
        // DETOX
        ext.kotlinVersion = '1.8.0'
        // DETOX END

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"

        // react-native-inappbrowser-reborn
        androidXAnnotation = "1.2.0"
        androidXBrowser = "1.3.0"
        // react-native-inappbrowser-reborn END
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("com.google.gms:google-services:4.3.15")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

        // DETOX
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        // DETOX END
    }
}

By changing the line to;

def enableHermes = true;

the same error throws for the original line, deep in the Sentry node_modles package

Ayan4 commented 11 months ago

Noob question, but why did you specifically chose v0.71.12 to upgrade to ? Why not upgrade to the latest one v0.72.3 ? I was researching about upgrading my app and was curious about the thought behind upgrading to a specific version and not the most recent one. Thanks!

AdarshJais commented 11 months ago

How you actually did your upgrade? Did you use any tool or manually implemented all changes mentioned inside (https://react-native-community.github.io/upgrade-helper/) ??

alexborton commented 11 months ago

Resolved this issue; human error. I was following the diff manually and missed this line (that was actually removed)

def enableHermes = project.ext.react.get("enableHermes", false);

I wanted to step through the major (technically minor) releases rather than going for the Hail Mary. In the end, we did go all the way to 72.x