facebook / react-native

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

Could not find any matches for com.facebook.react:react-native:+ as no versions of com.facebook.react:react-native are available. #37936

Closed sleaper closed 1 year ago

sleaper commented 1 year ago

Description

When I run npx react-native run-android I get this error:

* What went wrong:
Could not determine the dependencies of task ':react-native-async-storage_async-storage:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':react-native-async-storage_async-storage:debugCompileClasspath'.
   > Could not find any matches for com.facebook.react:react-native:+ as no versions of com.facebook.react:react-native are available.
     Required by:
         project :react-native-async-storage_async-storage

React Native Version

0.71.11

Output of npx react-native info

info Fetching system and libraries information... System: OS: Linux 5.19 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish) CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor Memory: 34.81 GB / 46.97 GB Shell: 5.8.1 - /usr/bin/zsh Binaries: Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.14.2/bin/yarn npm: 9.1.2 - ~/.nvm/versions/node/v16.14.2/bin/npm Watchman: Not Found SDKs: Android SDK: Not Found IDEs: Android Studio: AI-221.6008.13.2211.9477386 Languages: Java: 11.0.19 - /usr/bin/javac npmPackages: @react-native-community/cli: ^11.3.1 => 11.3.1 react: Not Found react-native: 0.71.11 => 0.71.11 npmGlobalPackages: react-native: Not Found

Steps to reproduce

Cannot reproduce

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

My android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        kotlinVersion = "1.7.0"
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33

        VisionCameraCodeScanner_targetSdkVersion = 33
        VisionCameraCodeScanner_compileSdkVersion = 33

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        // WARNING: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:4.3.14'
    }
}
github-actions[bot] commented 1 year ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - 0.71.11. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
sleaper commented 1 year ago

When I remove @react-native-async-storage/async-storage and try to rebuild. I get this error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':react-native-biometrics:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':react-native-biometrics:debugCompileClasspath'.
   > Could not find any matches for com.facebook.react:react-native:+ as no versions of com.facebook.react:react-native are available.
     Required by:
         project :react-native-biometrics
sleaper commented 1 year ago

Then when I remove react-native-biometrics and rebuild. I get this error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':react-native-bootsplash:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':react-native-bootsplash:debugCompileClasspath'.
   > Could not find any matches for com.facebook.react:react-native:+ as no versions of com.facebook.react:react-native are available.
     Required by:
         project :react-native-bootsplash
cortinico commented 1 year ago

@sleaper can you please share your android/app/build.gradle file?

sleaper commented 1 year ago

Sure, my android/app/build.gradle:

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'
import com.android.build.OutputFile

/**
 * This is the configuration block to customize your React Native Android app.
 * By default you don't need to apply any configuration, just uncomment the lines you need.
 */

react {
    /* Folders */
    //   The root of your project, i.e. where "package.json" lives. Default is '..'
    // 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 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 */
    //   The list of variants to that are debuggable. For those we're going to
    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    // debuggableVariants = ["liteDebug", "prodDebug"]
    /* Bundling */
    //   A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    //   The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    //   The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    //   The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    //   A list of extra flags to pass to the 'bundle' commands.
    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []
    /* Hermes Commands */
    //   The hermes compiler command to run. By default it is 'hermesc'
    //hermesCommand =  '../../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc'
    //
    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
}

apply from: "../../../node_modules/react-native-code-push/android/codepush.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.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore (JSC)
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US. Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Private function to get the list of Native Architectures you want to build.
 * This reads the value from reactNativeArchitectures in your gradle.properties
 * file and works together with the --active-arch-only flag of react-native run-android.
 */
def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    namespace "com.authier"
    defaultConfig {
        applicationId "com.authier"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 12
        versionName "1.0.9"
        missingDimensionStrategy 'react-native-camera', 'general'
        resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include (*reactNativeArchitectures())
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
         // release {
         //     Properties properties = new Properties()
         //     properties.load(project.rootProject.file('local.properties').newDataInputStream())
         //     storeFile file(properties.getProperty('storeFile'))
         //     keyAlias properties.getProperty('keyAlias')
         //     storePassword properties.getProperty('storePassword')
         //     keyPassword properties.getProperty('keyPassword')
         // }
    }
    buildTypes {
        debug {

            signingConfig signingConfigs.debug
        }
        releaseStaging {

            // Note: It's a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
            // Add the following line if not already there
            matchingFallbacks = ['release']

        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            //WARNING: signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

        }
    }

    // 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 {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")

    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
    implementation "androidx.core:core-splashscreen:1.0.0"

    implementation platform('com.google.firebase:firebase-bom:28.2.1')
    implementation 'com.google.firebase:firebase-analytics'

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

project.ext.vectoricons = [
        iconFontNames: ['Ionicons.ttf'] 
]

apply from: "../../../node_modules/react-native-vector-icons/fonts.gradle"
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
cortinico commented 1 year ago

apply from: "../../../node_modules/react-native-code-push/android/codepush.gradle"

apply from: "../../../node_modules/react-native-vector-icons/fonts.gradle"

Could you try to remove those 2 lines and report back if the issue is solved? I have the suspect you're using either a old version of CodePush or Vector Icons.

Moreover, could you share your package.json?

sleaper commented 1 year ago

apply from: "../../../node_modules/react-native-code-push/android/codepush.gradle"

apply from: "../../../node_modules/react-native-vector-icons/fonts.gradle"

Could you try to remove those 2 lines and report back if the issue is solved? I have the suspect you're using either a old version of CodePush or Vector Icons.

Moreover, could you share your package.json?

I removed those 2 lines and the error still persists. Here is my package.json:

{
  "name": "authier-mobile-app",
  "version": "1.0.9",
  "license": "AGPL-3.0-or-later",
  "scripts": {
    "android": "pnpm exec react-native run-android",
    "ios": "react-native run-ios",
    "start2": "react-native start --port 8088",
    "start": "react-native start",
    "start:nocache": "react-native start --reset-cache",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
    "adb:reverse": "adb reverse tcp:8088 tcp:8088",
    "gen": "graphql-codegen",
    "lingui:extract": "lingui extract",
    "lingui:compile": "lingui compile",
    "killPort": "lsof -ti tcp:8088 | xargs kill",
    "postinstall": "./scripts/copyNodeModulesHack.mjs",
    "pod:install": "cd ios && pod install",
    "cleanDerivedData": "rm -rf ~/Library/Developer/Xcode/DerivedData",
    "buildRelease": "cd android && ./gradlew clean && ./gradlew bundleRelease",
    "installBundle": "npx react-native run-android --mode=release",
    "postversion": "react-native-version"
  },
  "reactNativePermissionsIOS": [
    "Camera",
    "FaceID",
    "Notifications"
  ],
  "dependencies": {
    "@apollo/client": "^3.7.15",
    "@babel/preset-env": "^7.22.2",
    "@babel/preset-react": "^7.22.3",
    "@hookform/resolvers": "^2.9.11",
    "@lingui/core": "^4.2.0",
    "@lingui/react": "^4.2.0",
    "@react-native-clipboard/clipboard": "^1.11.2",
    "@react-native-community/cli": "^11.3.1",
    "@react-native-community/cli-platform-android": "^11.3.1",
    "@react-native-community/cli-platform-ios": "^11.3.1",
    "@react-native-community/netinfo": "^9.3.10",
    "@react-native-firebase/app": "^17.5.0",
    "@react-native-firebase/messaging": "^17.5.0",
    "@react-native-masked-view/masked-view": "^0.2.9",
    "@react-native/metro-config": "^0.72.6",
    "@react-navigation/bottom-tabs": "^6.5.7",
    "@react-navigation/drawer": "^6.6.2",
    "@react-navigation/material-top-tabs": "^6.6.2",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/native-stack": "^6.9.12",
    "@react-navigation/stack": "^6.3.16",
    "@rnx-kit/babel-preset-metro-react-native": "^1.1.4",
    "@rnx-kit/cli": "^0.16.9",
    "@rnx-kit/metro-config": "^1.3.6",
    "@rnx-kit/metro-resolver-symlinks": "^0.1.28",
    "@sentry/react-native": "5.5.0",
    "@shopify/flash-list": "^1.4.3",
    "@testing-library/react": "^14.0.0",
    "@ts-react/form": "^1.6.4",
    "apollo-link-http": "^1.5.17",
    "apollo-link-queue": "^3.1.0",
    "apollo-link-retry": "^2.2.16",
    "apollo-link-serialize": "^4.0.0",
    "apollo-link-token-refresh": "^0.6.0",
    "apollo3-cache-persist": "^0.14.1",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "cross-fetch": "^3.1.6",
    "date-fns": "^2.30.0",
    "formik": "^2.4.0",
    "graphql": "^16.6.0",
    "graphql-tools": "^9.0.0",
    "intl": "^1.2.5",
    "jest-environment-node": "^29.5.0",
    "jsc-android": "^250231.0.0",
    "jssha": "^3.3.0",
    "jwt-decode": "^3.1.2",
    "make-plural": "^7.3.0",
    "ms": "^2.1.3",
    "native-base": "^3.4.28",
    "query-string": "^8.1.0",
    "react": "18.2.0",
    "react-hook-form": "^7.44.2",
    "react-native": "0.71.11",
    "react-native-bootsplash": "4.7.0",
    "react-native-camera": "^4.2.1",
    "react-native-circular-progress-indicator": "^4.4.2",
    "react-native-code-push": "^8.0.2",
    "react-native-device-info": "^10.6.0",
    "react-native-fast-image": "^8.6.3",
    "react-native-gesture-handler": "2.10.1",
    "react-native-get-random-values": "^1.9.0",
    "react-native-gradle-plugin": "^0.72.1",
    "react-native-mmkv": "^2.8.0",
    "react-native-pager-view": "^6.2.0",
    "react-native-permissions": "^3.8.0",
    "react-native-qrcode-scanner": "^1.6.0",
    "react-native-reanimated": "^2.17.0",
    "react-native-safe-area-context": "4.5.3",
    "react-native-screens": "^3.20.0",
    "react-native-sensitive-info": "^6.0.0-alpha.9",
    "react-native-svg": "13.9.0",
    "react-native-tab-view": "^3.5.1",
    "react-native-url-polyfill": "^1.3.0",
    "react-native-uuid": "^2.0.1",
    "react-native-vector-icons": "^9.2.0",
    "react-native-vision-camera": "^2.15.4",
    "react-native-webview": "12.1.0",
    "react-native-webview-crypto": "^0.0.25",
    "react-query": "^3.39.3",
    "styled-system": "^5.1.5",
    "text-decoding": "^1.0.0",
    "vision-camera-code-scanner": "^0.2.0",
    "zod": "^3.21.4",
    "zustand": "^4.3.8",
    "zxcvbn-typescript": "^5.0.1"
  },
  "devDependencies": {
    "@apollo/react-testing": "^4.0.0",
    "@babel/core": "^7.22.1",
    "@babel/preset-typescript": "^7.21.5",
    "@babel/runtime": "^7.22.3",
    "@jest/globals": "^29.5.0",
    "@lingui/cli": "^4.2.0",
    "@lingui/macro": "^4.2.0",
    "@react-native-community/eslint-config": "^3.2.0",
    "@testing-library/react-native": "^12.1.2",
    "@types/crypto-js": "^4.1.1",
    "@types/jest": "^29.5.2",
    "@types/react": "^18.2.12",
    "@types/react-native": "^0.72.2",
    "@types/react-native-vector-icons": "^6.4.13",
    "@types/react-test-renderer": "^18.0.0",
    "appcenter-cli": "^2.13.8",
    "babel-jest": "^29.5.0",
    "babel-plugin-macros": "^3.1.0",
    "babel-plugin-module-resolver": "^5.0.0",
    "eslint": "^8.41.0",
    "jest": "^29.5.0",
    "metro-react-native-babel-preset": "0.76.5",
    "prettier": "^2.8.8",
    "pretty-quick": "^3.1.3",
    "react-native-codegen": "^0.72.0",
    "react-native-dotenv": "^3.4.8",
    "react-native-version": "^4.0.0",
    "react-test-renderer": "18.2.0",
    "typescript": "^5.1.3"
  },
  "jest": {
    "testEnvironmentOptions": {},
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ],
    "transformIgnorePatterns": [
      "node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)"
    ],
    "setupFiles": [
      "./jestSetup.js"
    ]
  }
}
cortinico commented 1 year ago
    "react-native-gradle-plugin": "^0.72.1",

You need to remove this line from your package.json (why you had it in the first place)?

sleaper commented 1 year ago
    "react-native-gradle-plugin": "^0.72.1",

You need to remove this line from your package.json (why you had it in the first place)?

It worked! We actually had this package for some time. I don't really remember why we added that. However yesterday it worked seamlessly. Maybe I forgot to update my node_modules. You are an absolute legend. Saved my day!

litinskii commented 11 months ago

this problem comes with react-native-screens@3.12.0 they add dependency

image

so if some one have additional deps on gradle there could be an error

abed-obaah commented 9 months ago

when i run eas build i get the

Running 'gradlew :app:bundleRelease' in /home/expo/workingdir/build/android Downloading https://services.gradle.org/distributions/gradle-7.5.1-all.zip 10% 20%. 30 %. 40%. 50%. 60%. 70%. 80% 90% 100% Welcome to Gradle 7.5.1! Here are the highlights of this release: