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

Android: Kotlin FAILED issue after upgrading to React Native v0.75.1 #1138

Open
1 of 5 tasks
codingslash76 opened this issue Aug 20, 2024 · 10 comments
Open
1 of 5 tasks
Labels
bug Something isn't working

Comments

@codingslash76
Copy link

What happened?

Recently, I have upgraded RN version to latest i.e. 0.75.1 and I am having following issue.
> Task :react-native-async-storage_async-storage:compileDebugKotlin FAILED
Library Version Used - @react-native-async-storage/[email protected]

Version

1.24.0

What platforms are you seeing this issue on?

  • Android
  • iOS
  • macOS
  • Windows
  • web

System Information

System:
  OS: macOS 14.4.1
  CPU: (8) arm64 Apple M1
  Memory: 123.66 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.5.1
    path: /opt/homebrew/bin/node
  Yarn: Not Found
  npm:
    version: 10.8.2
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.07.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12169540
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 3.3.4
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.1
    wanted: 0.75.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to Reproduce

Unable to build after upgrading.

Screenshot 2024-08-20 at 9 25 20 PM

@codingslash76 codingslash76 added the bug Something isn't working label Aug 20, 2024
@mensonones
Copy link
Contributor

Would you have a link to a repository that reproduces the problem? I tried running it here in the newest version of React Native and the library, with newArch true and it worked.

@karanrampal04
Copy link

Hey, I'm facing the same issue, when updating to react-native's latest version, getting this issue: Task :react-native-async-storage_async-storage:compileDebugKotlin FAILED

@mensonones
Copy link
Contributor

Would you have a link to a repository that reproduces the problem? I tried running it here in the newest version of React Native and the library, with newArch true and it worked.

Would you have a link to a repository that reproduces the problem? I tried running it here in the newest version of React Native and the library, with newArch true and it worked.

@codingslash76
Copy link
Author

@mensonones
Repository I am currently working on is private and cannot be shared here. I have attached the package.json used for my project. We are not using New Architecture.

Have you tried it on Mac with RN 0.75.1 and New Architecture disabled?

{
"dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.6.0",
    "@fortawesome/free-brands-svg-icons": "^6.6.0",
    "@fortawesome/free-solid-svg-icons": "^6.6.0",
    "@fortawesome/pro-duotone-svg-icons": "^6.6.0",
    "@fortawesome/pro-light-svg-icons": "^6.6.0",
    "@fortawesome/pro-regular-svg-icons": "^6.6.0",
    "@fortawesome/pro-solid-svg-icons": "^6.6.0",
    "@fortawesome/react-native-fontawesome": "^0.3.2",
    "@fortawesome/sharp-light-svg-icons": "^6.6.0",
    "@fortawesome/sharp-regular-svg-icons": "^6.6.0",
    "@gorhom/bottom-sheet": "^4.6.4",
    "@react-native-async-storage/async-storage": "^1.24.0",
    "@react-native-camera-roll/camera-roll": "^7.8.3",
    "@react-native-community/blur": "^4.4.0",
    "@react-native-community/datetimepicker": "^7.7.0",
    "@react-native-community/geolocation": "^3.3.0",
    "@react-native-community/netinfo": "^11.3.2",
    "@react-native-community/slider": "^4.5.2",
    "@react-native-firebase/app": "^18.7.3",
    "@react-native-firebase/messaging": "^18.7.3",
    "@react-native-picker/picker": "^2.4.0",
    "@react-navigation/drawer": "^6.7.2",
    "@react-navigation/native": "^6.1.18",
    "@react-navigation/stack": "^6.4.1",
    "@stripe/stripe-react-native": "^0.38.4",
    "axios": "^1.7.2",
    "buffer": "^6.0.3",
    "deprecated-react-native-prop-types": "^2.3.0",
    "lodash": "^4.17.21",
    "moment": "^2.30.1",
    "native-base": "^3.4.28",
    "prop-types": "^15.8.1",
    "react": "18.3.1",
    "react-native": "0.75.1",
    "react-native-add-calendar-event": "^5.0.0",
    "react-native-blob-util": "^0.19.11",
    "react-native-camera": "^4.2.1",
    "react-native-detector": "^0.2.3",
    "react-native-document-picker": "^9.3.0",
    "react-native-geolocation-service": "^5.3.1",
    "react-native-gesture-handler": "^2.18.1",
    "react-native-image-crop-picker": "^0.40.3",
    "react-native-image-picker": "^7.1.2",
    "react-native-image-viewing": "^0.2.2",
    "react-native-inappbrowser-reborn": "^3.7.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-media-controls": "^2.3.0",
    "react-native-modal-datetime-picker": "^17.1.0",
    "react-native-pdf": "^6.7.5",
    "react-native-permissions": "^4.1.5",
    "react-native-picker-select": "^9.2.0",
    "react-native-qrcode-scanner": "^1.5.5",
    "react-native-qrcode-svg": "^6.3.1",
    "react-native-reanimated": "^3.15.0",
    "react-native-safe-area-context": "^4.10.9",
    "react-native-screens": "^3.34.0",
    "react-native-share": "^10.2.1",
    "react-native-slider": "^0.11.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-sound": "^0.11.2",
    "react-native-svg": "^14.2.0",
    "react-native-swipe-gestures": "^1.0.5",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-swiper": "^1.6.0",
    "react-native-switch-selector": "^2.3.0",
    "react-native-webview": "^13.10.5",
    "react-redux": "^9.1.2",
    "redux": "^5.0.1",
    "rive-react-native": "^7.3.0",
  },
  "devDependencies": {
    "@babel/core": "^7.24.9",
    "@babel/preset-env": "^7.24.8",
    "@babel/runtime": "^7.24.8",
    "@react-native/babel-preset": "0.75.1",
    "@react-native/eslint-config": "0.75.1",
    "@react-native/metro-config": "0.75.1",
    "@react-native/typescript-config": "0.75.1",
    "@types/react": "^18.3.1",
    "@types/react-test-renderer": "^18.3.0",
    "@welldone-software/why-did-you-render": "^8.0.3",
    "babel-jest": "^29.6.3",
    "eslint": "^8.57.0",
    "jest": "^29.6.3",
    "patch-package": "^8.0.0",
    "prettier": "^2.8.8",
    "react-devtools": "^5.3.1",
    "react-devtools-core": "^5.3.1",
    "react-test-renderer": "18.2.0",
    "typescript": "^5.5.4"
  },
  "engines": {
    "node": ">=18"
  },
}

@mensonones
Copy link
Contributor

"@react-native-async-storage/async-storage": "^1.24.0",
Hey, @codingslash76!

I generated a new project in version 0.75.1 and with version 1.24.0 of the library and with newArch disabled and I did not get the problem. If I can try to help, if you have a repository with the minimum reproduction of this problem.

@waenSaran
Copy link

Hi, I have the same issue here when I try to upgrade

  • API 33 to 34
  • node 16 to 18
  • react-native from 0.67.3 -> 0.75.4 (already follows this instruction: upgrade-helper)
  • react 17.0.2 -> 18.3.1
  • replace @react-native-community/async-storage with @react-native-async-storage/async-storage

package.json

{
  "name": "PWA",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start -- --reset-cache",
    "test": "jest",
    "lint": "eslint .",
    "android-build": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android",
    "build:ios": "npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios"
  },
  "dependencies": {
    "@formatjs/intl-datetimeformat": "^4.1.5",
    "@formatjs/intl-displaynames": "^5.1.5",
    "@formatjs/intl-getcanonicallocales": "^1.7.1",
    "@formatjs/intl-listformat": "^6.2.5",
    "@formatjs/intl-locale": "^2.4.32",
    "@formatjs/intl-numberformat": "^7.1.4",
    "@formatjs/intl-pluralrules": "^4.0.27",
    "@formatjs/intl-relativetimeformat": "^9.1.6",
    "@react-native-async-storage/async-storage": "^2.0.0",
    "@react-native-community/checkbox": "^0.5.8",
    "@react-native-community/datetimepicker": "^3.5.2",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-picker/picker": "^1.16.3",
    "@react-navigation/bottom-tabs": "^5.11.11",
    "@react-navigation/material-bottom-tabs": "^5.3.15",
    "@react-navigation/material-top-tabs": "^5.3.15",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "^5.14.5",
    "axios": "^0.21.1",
    "moment": "^2.29.1",
    "native-base": "^3.1.0",
    "react": "18.3.1",
    "react-native": "0.75.4",
    "react-native-awesome-alerts": "^1.5.2",
    "react-native-code-push": "^8.0.0",
    "react-native-device-info": "^8.4.5",
    "react-native-elements": "^3.4.1",
    "react-native-exit-app": "^1.1.0",
    "react-native-fs": "^2.20.0",
    "react-native-geolocation-service": "^5.3.1",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-image-crop-picker": "^0.40.0",
    "react-native-image-resizer": "^1.4.5",
    "react-native-iphone-x-helper": "^1.3.1",
    "react-native-loading-spinner-overlay": "^2.0.0",
    "react-native-localize": "^2.1.1",
    "react-native-modal": "^13.0.0",
    "react-native-pager-view": "^5.2.1",
    "react-native-paper": "^4.9.1",
    "react-native-paper-dates": "^0.4.6",
    "react-native-permissions": "3.6.1",
    "react-native-picker-select": "^8.0.4",
    "react-native-qrcode-scanner": "^1.5.4",
    "react-native-qrcode-svg": "^6.1.1",
    "react-native-reanimated": "^2.2.4",
    "react-native-safe-area-context": "^3.3.0",
    "react-native-screens": "^3.3.0",
    "react-native-select-dropdown": "^1.1.0",
    "react-native-svg": "^12.1.1",
    "react-native-tab-view": "^3.0.1",
    "react-native-vector-icons": "^8.1.0",
    "react-native-view-shot": "^3.1.2",
    "react-native-vision-camera": "^4.5.3",
    "react-native-webview": "^11.22.7",
    "react-native-woodpicker": "^0.3.9",
    "react-redux": "^7.2.4",
    "redux": "^4.1.0",
    "redux-devtools-extension": "^2.13.9",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0",
    "styled-components": "^5.3.0",
    "styled-system": "^5.1.5"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.75.4",
    "@react-native/eslint-config": "0.75.4",
    "@react-native/metro-config": "0.75.4",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.3.1"
  },
  "engines": {
    "node": ">=18"
  },
  "packageManager": "[email protected]"
}

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 23
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "26.1.10909125"
        kotlinVersion = "1.9.24"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
    }
}

// to write package's namespace
subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                // Set namespace based on package name from AndroidManifest.xml
                def manifestFile = file("${project.projectDir}/src/main/AndroidManifest.xml")
                if (manifestFile.exists()) {
                    def manifestContent = manifestFile.getText('UTF-8')
                    def packageName = manifestContent.find(/package="([^"]+)"/) { match, p -> p }
                    if (packageName) {
                        namespace = packageName // Set namespace to packageName
                    } else {
                        // Fallback to a default namespace if package is not found
                        def defaultNamespace = project.group.toString().replace('.', '_')
                        namespace = defaultNamespace
                    }
                } else {
                    // Fallback if no manifest file found
                    def defaultNamespace = project.group.toString().replace('.', '_')
                    namespace = defaultNamespace
                }

                buildFeatures {
                    buildConfig = true
                }
            }

            // Task to ensure package attribute is removed
            project.tasks.register("fixManifestsAndNamespace") {
                doLast {
                    // Remove package attribute from AndroidManifest.xml
                    def manifests = fileTree(dir: project.projectDir, includes: ['**/AndroidManifest.xml'])
                    manifests.each { File manifestFile ->
                        def manifestContent = manifestFile.getText('UTF-8')
                        if (manifestContent.contains('package=')) {
                            println "Removing package attribute from ${manifestFile}"
                            manifestContent = manifestContent.replaceAll(/package="[^"]*"/, '')
                            manifestFile.write(manifestContent, 'UTF-8')
                        }
                    }
                }
            }

            // Ensure the task runs before the build process
            project.tasks.matching { it.name.startsWith("preBuild") }.all {
                dependsOn project.tasks.named("fixManifestsAndNamespace")
            }
        }
    }
}

apply plugin: "com.facebook.react.rootproject"

gradle.properties

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# 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.
hermesEnabled=true

# Try building without Frame Processors 
# ref: https://react-native-vision-camera.com/docs/guides/troubleshooting#build-issues-1
VisionCamera_enableFrameProcessors=false

# https://react-native-async-storage.github.io/async-storage/docs/advanced/next#add-config-flag
AsyncStorage_useNextStorage=true

# https://react-native-async-storage.github.io/async-storage/docs/advanced/next#configuration
AsyncStorage_kotlinVersion=1.9.24
AsyncStorage_next_roomVersion=2.6.1
AsyncStorage_next_kspVersion=1.9.24-1.0.20

android\gradle\wrapper\gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

android\setting.gradle

pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }

rootProject.name = 'PWA'

include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
include ':react-native-vision-camera'
project(':react-native-vision-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vision-camera/android')
include ':react-native-permissions'
project(':react-native-permissions').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-permissions/android')
include ':react-native-safe-area-context'
project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-safe-area-context/android')
include ':react-native-screens'
project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android')
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
include ':react-native-async-storage_async-storage'
project(':react-native-async-storage_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-async-storage/async-storage/android')
include ':react-native-pager-view'
project(':react-native-pager-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pager-view/android')
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')

Steps to Reproduce

  • remove node_modules and yarn.lock
  • upgrade yarn
  • gradlew clean
  • remove ndk and rebuild gradle

@mensonones
Copy link
Contributor

hey, @waenSaran! if possible provide a minimal example of reproducing the problem

@waenSaran
Copy link

waenSaran commented Oct 30, 2024

@mensonones
Yesterday, I just try to do all the below steps and it just worked (Maybe cause by its version)

  1. yarn remove @react-native-async-storage/async-storage
  2. rm -rf node_modules && rm -rf yarn.lock
  3. yarn (re-install all)
  4. cd android && .\gradlew clean
  5. cd .. && yarn android (or yarn run react-native run-android)

Follow the above steps, the error has gone. I still confused whether it is about the Gradle version not compatible?

@redbluenat
Copy link

I have the error:
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method getKspVersion() for arguments [build_dyy2brmx05n7z58u4j62a6bzz$_run_closure1$_closure2$_closure5@4392b5c2] on project ':react-native-async-storage_async-storage' of type org.gradle.api.Project.

@mensonones
Copy link
Contributor

Hi, @redbluenat! Can you reproduce the problem in a repository and share?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants