facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.18k stars 24.32k forks source link

Newer React-Native Version 0.71.0 not running #35900

Closed Malik-Usman17 closed 1 year ago

Malik-Usman17 commented 1 year ago

Description

When I am running newly build project it gives me these errors:

`FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\malik.usman\Desktop\Malik Usman\React Native Projects\MyApp\android\app\build.gradle' line: 2

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find implementation class 'com.facebook.react.ReactPlugin' for plugin 'com.facebook.react' specified in jar:file:/C:/Users/malik.usman/.gradle/caches/jars-9/20363358361f313985ae969d544ea93f/react-native-gradle-plugin.jar!/META-INF/gradle-plugins/com.facebook.react.properties.

* 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.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 13s

Version

0.71.0

Output of npx react-native info

info Fetching system and libraries information... error Unable to print environment info. Error: Command failed: wmic os get Caption 'wmic' is not recognized as an internal or external command, operable program or batch file.

Steps to reproduce

When I am building my react-native project through command prompt, I am running this line npx react-native run-android.

Snack, code example, screenshot, or link to a repository

npx react-native run-android

cortinico commented 1 year ago

When I am building my react-native project through command prompt, I am running this line npx react-native run-android.

Does the issue happens also from PowerShell?

Malik-Usman17 commented 1 year ago

@cortinico yes I also tried on power shell, gives me same errors.

cortinico commented 1 year ago

That's a odd issue.

One question to help me understand: is this file existing in your setup?

./node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt

What's the content of it?

Malik-Usman17 commented 1 year ago

@cortinico yes the file exist and the content is this: `/*

package com.facebook.react

import com.android.build.api.variant.AndroidComponentsExtension import com.android.build.gradle.AppExtension import com.android.build.gradle.internal.tasks.factory.dependsOn import com.facebook.react.tasks.BuildCodegenCLITask import com.facebook.react.tasks.GenerateCodegenArtifactsTask import com.facebook.react.tasks.GenerateCodegenSchemaTask import com.facebook.react.utils.AgpConfiguratorUtils.configureBuildConfigFields import com.facebook.react.utils.AgpConfiguratorUtils.configureDevPorts import com.facebook.react.utils.BackwardCompatUtils.configureBackwardCompatibilityReactMap import com.facebook.react.utils.DependencyUtils.configureDependencies import com.facebook.react.utils.DependencyUtils.configureRepositories import com.facebook.react.utils.DependencyUtils.readVersionString import com.facebook.react.utils.JsonUtils import com.facebook.react.utils.NdkConfiguratorUtils.configureReactNativeNdk import com.facebook.react.utils.ProjectUtils.needsCodegenFromPackageJson import com.facebook.react.utils.findPackageJsonFile import java.io.File import kotlin.system.exitProcess import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task import org.gradle.internal.jvm.Jvm

class ReactPlugin : Plugin { override fun apply(project: Project) { checkJvmVersion(project) val extension = project.extensions.create("react", ReactExtension::class.java, project)

// App Only Configuration
project.pluginManager.withPlugin("com.android.application") {
  project.afterEvaluate {
    val reactNativeDir = extension.reactNativeDir.get().asFile
    val propertiesFile = File(reactNativeDir, "ReactAndroid/gradle.properties")
    val versionString = readVersionString(propertiesFile)
    configureDependencies(project, versionString)
    configureRepositories(project, reactNativeDir)
  }

  configureReactNativeNdk(project, extension)
  configureBuildConfigFields(project)
  configureDevPorts(project)
  configureBackwardCompatibilityReactMap(project)

  project.extensions.getByType(AndroidComponentsExtension::class.java).apply {
    onVariants(selector().all()) { variant ->
      project.configureReactTasks(variant = variant, config = extension)
    }
  }

  // This is a legacy AGP api. Needed as AGP 7.3 is not consuming generated resources correctly.
  // Can be removed as we bump to AGP 7.4 stable.
  // This registers the $buildDir/generated/res/react/<variant> folder as a
  // res folder to be consumed with the old AGP Apis which are not broken.
  project.extensions.getByType(AppExtension::class.java).apply {
    this.applicationVariants.all { variant ->
      val isDebuggableVariant =
          extension.debuggableVariants.get().any { it.equals(variant.name, ignoreCase = true) }
      val targetName = variant.name.replaceFirstChar { it.uppercase() }
      val bundleTaskName = "createBundle${targetName}JsAndAssets"
      if (!isDebuggableVariant) {
        variant.registerGeneratedResFolders(
            project.layout.buildDirectory.files("generated/res/react/${variant.name}"))
        variant.mergeResourcesProvider.get().dependsOn(bundleTaskName)
      }
    }
  }
  configureCodegen(project, extension, isLibrary = false)
}

// Library Only Configuration
project.pluginManager.withPlugin("com.android.library") {
  configureCodegen(project, extension, isLibrary = true)
}

}

private fun checkJvmVersion(project: Project) { val jvmVersion = Jvm.current()?.javaVersion?.majorVersion if ((jvmVersion?.toIntOrNull() ?: 0) <= 8) { project.logger.error( """

  ********************************************************************************

  ERROR: requires JDK11 or higher.
  Incompatible major version detected: '$jvmVersion'

  ********************************************************************************

  """
          .trimIndent())
  exitProcess(1)
}

}

/**

devoren commented 1 year ago

Have you tried deleting gradle caches?

cortinico commented 1 year ago

Yes, please try to delete the .gradle folder inside your home and try again

cortinico commented 1 year ago

Yes, please try to delete the .gradle folder inside your home and try again

Malik-Usman17 commented 1 year ago

@cortinico if your guyz talking about the .gradle which lie under my project android folder then yes , i tried it also , then again run my project with command npx react-native run-android but no luck, still same errors.

RamanDEEP225 commented 1 year ago

@cortinico , i also tried by deleting .gradle but getting this error Could not resolve com.facebook.react:react-android:0.71.0

RamanDEEP225 commented 1 year ago

Could not determine the dependencies of task ':app:mergeReleaseNativeLibs'.

Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'. Could not find com.facebook.fresco:fresco:2.2.0. Searched in the following locations:

  • https://repo.maven.apache.org/maven2/com/facebook/fresco/fresco/2.2.0/fresco-2.2.0.pom
  • https://oss.sonatype.org/content/repositories/snapshots/com/facebook/fresco/fresco/2.2.0/fresco-2.2.0.pom node_modules/jsc-android/dist/com/facebook/fresco/fresco/2.2.0/fresco-2.2.0.pom
  • https://dl.google.com/dl/android/maven2/com/facebook/fresco/fresco/2.2.0/fresco-2.2.0.pom
  • https://www.jitpack.io/com/facebook/fresco/fresco/2.2.0/fresco-2.2.0.pom Required by: project :app Could not find com.facebook.react:react-android:0.71.0. Searched in the following locations: node_modules/react-native/android/com/facebook/react/react-android/0.71.0/react-android-0.71.0.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :app Could not find com.facebook.react:hermes-android:0.71.0. Searched in the following locations: node_modules/react-native/android/com/facebook/react/hermes-android/0.71.0/hermes-android-0.71.0.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :app Could not find com.facebook.react:react-android:0.71.0. Searched in the following locations: react-native/android/com/facebook/react/react-android/0.71.0/react-android-0.71.0.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :app > project :react-native-splash-screen project :app > project :react-native-restart project :app > project :@react-native-firebase_analytics project :app > project :@react-native-community_art project :app > project :@react-native-firebase_app project :app > project :@react-native-firebase_database project :app > project :@react-native-firebase_messaging project :app > project :@react-native-community_clipboard project :app > project :react-native-add-calendar-event project :app > project :intercom-react-native project :app > project :@react-native-community_toolbar-android project :app > project :@react-native-community_blur project :app > project :react-native-gesture-handler project :app > project :react-native-device-info project :app > project :react-native-background-timer project :app > project :lottie-react-native project :app > project :react-native-picker project :app > project :react-native-maps project :app > project :rn-fetch-blob project :app > project :react-native-permissions project :app > project :react-native-geolocation-service project :app > project :react-native-navigation project :app > project :@react-native-firebase_crashlytics project :app > project :react-native-orientation project :app > project :react-native-pager-view project :app > project :@react-native-community_async-storage project :app > project :react-native-keychain project :app > project :intercom_intercom-react-native project :app > project :invertase_react-native-apple-authentication project :app > project :react-native-community_art project :app > project :react-native-community_async-storage project :app > project :react-native-community_blur project :app > project :react-native-community_cameraroll project :app > project :react-native-community_checkbox project :app > project :react-native-community_clipboard project :app > project :react-native-community_datetimepicker project :app > project :react-native-community_netinfo project :app > project :react-native-community_picker project :app > project :react-native-community_toolbar-android project :app > project :react-native-firebase_analytics project :app > project :react-native-firebase_app project :app > project :react-native-firebase_crashlytics project :app > project :react-native-firebase_database project :app > project :react-native-firebase_dynamic-links project :app > project :react-native-firebase_messaging project :app > project :react-native-google-signin_google-signin project :app > project :bugsnag-react-native project :app > project :react-native-device-country project :app > project :react-native-fast-image project :app > project :react-native-fs project :app > project :react-native-image-crop-picker project :app > project :react-native-inappbrowser-reborn project :app > project :react-native-linear-gradient project :app > project :react-native-localization project :app > project :react-native-month-year-picker project :app > project :react-native-snackbar project :app > project :react-native-spinkit project :app > project :react-native-vector-icons project :app > project :react-native-video project :app > project :react-native-webview project :app > project :rn-sms-retriever Could not find com.eightbitlab:blurview:1.6.3. Searched in the following locations:
  • https://repo.maven.apache.org/maven2/com/eightbitlab/blurview/1.6.3/blurview-1.6.3.pom
  • https://oss.sonatype.org/content/repositories/snapshots/com/eightbitlab/blurview/1.6.3/blurview-1.6.3.pom
  • /node_modules/jsc-android/dist/com/eightbitlab/blurview/1.6.3/blurview-1.6.3.pom
  • https://dl.google.com/dl/android/maven2/com/eightbitlab/blurview/1.6.3/blurview-1.6.3.pom
  • https://www.jitpack.io/com/eightbitlab/blurview/1.6.3/blurview-1.6.3.pom Required by: project :app > project :@react-native-community_blur project :app > project :react-native-community_blur Could not find com.facebook.react:react-android:0.71.0. Searched in the following locations:
  • node_modules/react-native/android/com/facebook/react/react-android/0.71.0/react-android-0.71.0.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :app > project :react-native-mmkv

Possible solution:

Getting these errors, anybody help to resolve these.

Malik-Usman17 commented 1 year ago

Don't know how but I just solved it, by deleting the node_modules folder of my project and then re-running the project, it worked perfectly fine. Lastly thank you all for your involvement.

@cortinico

yashafromrussia commented 1 year ago

In case this helps someone - I followed the manual upgrade guide, but missed removing the following line in android/app/build.gradle:

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

Removing it resolved the issue for me πŸš€

Azharul-Raj commented 1 year ago

Don't know how but I just solved it, by deleting the node_modules folder of my project and then re-running the project, it worked perfectly fine. Lastly thank you all for your involvement.

@cortinico

I'm having the same error but even after deleting node modules, it doesn't work. Throwing the same error.

devoren commented 1 year ago

@Azharul-Raj try to delete .gradle caches folder inside your home

thezaidbintariq commented 1 year ago

@Azharul-Raj try running project using "yarn start" command.

Malik-Usman17 commented 1 year ago

Don't know how but I just solved it, by deleting the node_modules folder of my project and then re-running the project, it worked perfectly fine. Lastly thank you all for your involvement. @cortinico

I'm having the same error but even after deleting node modules, it doesn't work. Throwing the same error.

The first thing you need to do is try to delete your .gradle folder and then run your project again. If you still face the same error, then try to delete your node_modules folder and then add your packages again by running yarn install or npm install whatever package manager you are using and after that run your project again.

Azharul-Raj commented 1 year ago

I had an environment setup issue. Now it's ok

ZohaibAhmad786 commented 1 year ago

delete node_module folder and then install the libraries. i have followed the above steps and now my app is working

Arif-Malik-N commented 1 year ago

worked for me by deleting .gradle folder and node_modules

serdarmengutay commented 1 year ago

I deleted to node_modules and command npm install just worked for me

Ravimahar5695 commented 1 year ago

Deleting ".gradle" and "node_modules" folders worked for me. Thanks to all πŸ‘πŸ‘πŸ‘

zohaib000 commented 1 year ago

which .gradle folder you are talking about ??

the folder inside android directory or in users/zohaib/gradle

zohaib000 commented 1 year ago

please tell me asap Thanks

Malik-Usman17 commented 1 year ago

which .gradle folder you are talking about ??

the folder inside android directory or in users/zohaib/gradle

yes, you have a folder named .gradle folder in your android folder (and not gradle folder)

devjs1000 commented 1 year ago

I have resolved this with simple solution

just do rm -rf node_modules then do yarn install after that it will work

deepbag commented 1 year ago

delete android/.gradle and node_modules and again run npm I and run android command it will work fine!

Caltus124 commented 11 months ago

For this to work, you need to delete the "node_modules" folder and the android/.gradle file, and finally, you need to do a "npm i" and a ./gradlew clean in the android folder.

aybarska commented 8 months ago

cleaning .gradle and node modules didnt worked on my case

devjs1000 commented 8 months ago

cleaning .gradle and node modules didnt worked on my case

Try chmod +x .gradlew Could be you have cloned project from someone else and this file is throwing error coz it doesn't have exec permission

ZohaibAhmad786 commented 8 months ago

Try this boises rm -rf node_modules && npm cache clean --force && yarn install && watchman watch-del-all && rm -rf $TMPDIR/haste-map-* && rm -rf $TMPDIR/metro-cache