facebook / react-native

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

could not find com.facebook.react:react-android:0.71.3 #36234

Closed SharvanTech5 closed 1 year ago

SharvanTech5 commented 1 year ago

New Version

0.61.4

Old Version

0.71.3

Build Target(s)

android

Output of react-native info

System: OS: macOS 12.2 CPU: (8) arm64 Apple M1 Memory: 95.97 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.19.0 - /opt/homebrew/opt/node@16/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.19.3 - /opt/homebrew/opt/node@16/bin/npm Watchman: 2022.11.07.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 18.0.1.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.3 => 0.71.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Issue and Reproduction Steps

react-native run-android Output:

cortinico commented 1 year ago

Please provide:

SharvanTech5 commented 1 year ago

settings/build.gradle

rootProject.name = 'projectname'
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')
include ':app', ':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-moengage'
project(':react-native-moengage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-moengage/android')

android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

buildscript {
    ext {
         buildToolsVersion = "33.0.0"
         minSdkVersion = 21
         compileSdkVersion = 33
         targetSdkVersion = 33
         kotlinVersion = "1.5.31"
         supportLibVersion = "31.0.0"

        // Any of the following will work
        googlePlayServicesVersion      = "17.0.0"

       ndkVersion = "23.1.7779620"
    }
   //  ext.kotlin_version = '1.5.20' //put the version you just updated to

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        //classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
       // classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // firebase 
        classpath 'com.google.gms:google-services:4.3.10'
        // Add the dependency for the Crashlytics Gradle plugin
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
    }
}

allprojects {
    repositories {
        exclusiveContent {
            // We get React Native's Android binaries exclusively through npm,
            // from a local Maven repo inside node_modules/react-native/.
            // (The use of exclusiveContent prevents looking elsewhere like Maven Central
            // and potentially getting a wrong version.)
            filter {
                includeGroup "com.facebook.react"
            }
            forRepository {
                maven {
                    // NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android"
                    url "$rootDir/../node_modules/react-native/android"
                }
            }
        }
        google()
        mavenCentral()
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // paytm all in one sdk
            url "https://artifactory.paytm.in/libs-release-local"
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        // add below code - start
        configurations.all {
            resolutionStrategy {
                force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION

                // use 0.9.0 to fix crash on Android 11
                force "com.facebook.soloader:soloader:0.9.0+"
               // force 'com.facebook.react:react-native:0.71.3'
            }
        }
        // code - end
        google()
        maven { url 'https://www.jitpack.io' }

    }
}

### android/app/build.gradle

apply plugin: "com.android.application"
//apply plugin: 'kotlin-android'
apply plugin: "com.facebook.react"

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

 /**
project.ext.react = [
//    entryFile: "index.ts",
    entryFile: "index.js",
    enableHermes: true,  // clean and rebuild if changing
]

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

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * 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:+'

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.demo.packageName"

    defaultConfig {
        applicationId "com.demo.packageName"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 55 //41.1.3.13
        versionName "1.2.19"
        multiDexEnabled true

        resValue "string", "build_config_package", "com.demo.packageName"
        resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())

        ndk {
            // abiFilters "armeabi-v7a", "x86", "arm64-v8a"
            abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
        }
    }
    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 {
      storeFile file('keyStore.keystore')
      storePassword ''
      keyAlias ''
      keyPassword ''
    }
    }
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    buildTypes {
        debug {
           signingConfig signingConfigs.debug
         }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            // Add this extension
            // signingConfig signingConfigs.debug
            signingConfig signingConfigs.release
            minifyEnabled false
           // useProguard false
            //shrinkResources false
            //debuggable true
            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)
            }
        }
    }
    packagingOptions {
       pickFirst 'lib/x86/libc++_shared.so'
       pickFirst 'lib/x86_64/libjsc.so'
       pickFirst 'lib/arm64-v8a/libjsc.so'
       pickFirst 'lib/arm64-v8a/libc++_shared.so'
       pickFirst 'lib/x86_64/libc++_shared.so'
       pickFirst 'lib/armeabi-v7a/libc++_shared.so'
     }

      repositories {
         flatDir {
             dirs 'libs'
         }
      }
}

dependencies {

    implementation 'com.android.support:multidex:1.0.3'
    implementation fileTree(dir: "libs", include: ["*.jar","*.aar"])
    //noinspection GradleDynamicVersion
   // implementation("com.facebook.react:react-android")
    //implementation 'com.facebook.react:react-native:0.71.3!!'
implementation "com.facebook.react:react-native:+"
    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")

    implementation 'com.appsflyer:af-android-sdk:5.4.3'

    // animated gif
    implementation 'com.facebook.fresco:animated-gif:2.0.0'

    // google maps
    // implementation(project(':react-native-maps')){
    //    exclude group: 'com.google.android.gms', module: 'play-services-base'
    //    exclude group: 'com.google.android.gms', module: 'play-services-maps'
    // }
    // implementation 'com.google.android.gms:play-services-base:17.6.0'
    // implementation 'com.google.android.gms:play-services-maps:17.0.1'
    // implementation 'com.google.android.gms:play-services-tasks:17.2.1'
    // implementation 'com.google.android.gms:play-services-basement:17.6.0'
    // implementation 'com.google.android.play:core:1.10.3'

//Comment by sharvan for RN update
    // firebase
//     implementation platform('com.google.firebase:firebase-bom:28.4.1')
//     implementation 'com.google.firebase:firebase-analytics'
//     implementation 'com.google.firebase:firebase-crashlytics'
//     implementation 'com.google.firebase:firebase-crashlytics-ndk'
//     implementation 'com.google.firebase:firebase-auth'
//     implementation 'com.google.firebase:firebase-core'
//     implementation 'com.google.firebase:firebase-messaging'
//     implementation 'com.google.firebase:firebase-installations'
//     implementation 'me.leolin:ShortcutBadger:1.1.22@aar' // for android badges
//     //SafetyNet is a set of APIs from Google Play Services for developers to ensure that apps are running in a safe environment.
//    // implementation('com.google.firebase:firebase-auth') {
//     //    exclude module: "play-services-safetynet"
//     //}
//     // replacing this instid of play-services-safetynet
//     // Add the dependency for the App Check library
//     // When using the BoM, you don't specify versions in Firebase library dependencies
//     implementation 'com.google.firebase:firebase-appcheck-playintegrity'

    // paytm payment gateway dependencies
    implementation "com.squareup.okhttp3:okhttp:4.9.1"
    implementation "com.squareup.okhttp3:logging-interceptor:4.2.1"
    implementation "com.squareup.okhttp3:okhttp-urlconnection:4.9.1"

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        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
    }

    implementation("com.moengage:moe-android-sdk:12.3.02") {
    exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib" // ADD this line

    }
    //Moengage
    //Configuring HMS Push Kit
    implementation("com.moengage:hms-pushkit:4.3.0")
    //Configuring Xiaomi Push 
    implementation("com.moengage:push-amp-plus:6.0.0")

    implementation("androidx.core:core:1.6.0")
    implementation("androidx.appcompat:appcompat:1.3.1")
    implementation("androidx.lifecycle:lifecycle-process:2.4.0")

    implementation project(':react-native-screens')
    implementation 'com.facebook.soloader:soloader:0.9.0+'

}

//add below script
configurations.all {
    exclude group: 'com.google.android.gms', module: 'play-services-safetynet'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

// firebase
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
github-actions[bot] commented 1 year ago
:warning: Missing Reproducible Example
:information_source: It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.
cortinico commented 1 year ago

You setup looks correct to me. Can you create a repro?

redpanda-bit commented 1 year ago

I was able to reproduce after copying and pasting the provided files into a new npx react-native init AwesomeProject --version=0.71.3 project.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not find com.facebook.react:react-android:0.71.3.
     Required by:
         project :app
   > Could not find com.facebook.react:hermes-android:0.71.3.
     Required by:
         project :app
Ashish-5566 commented 1 year ago

I am also facing same issue @SharvanTech5

verochan commented 1 year ago

I'm also suffering this error after updating from 0.70.7 to 0.71.3 using align-deps:

npx @rnx-kit/align-deps --requirements react-native@0.71 --write

This is the complete error:

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 -PreactNativeDebugArchitectures=arm64-v8a -PreactNativeArchitectures=arm64-v8a

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.facebook.react:react-native:0.71.3.
     Searched in the following locations:
       - file:/Users/verochan/app-native/node_modules/react-native/android/com/facebook/react/react-native/0.71.3/react-native-0.71.3.pom
       - file:/Users/verochan/app-native/node_modules/jsc-android/dist/com/facebook/react/react-native/0.71.3/react-native-0.71.3.pom
       - file:/Users/verochan/.m2/repository/com/facebook/react/react-native/0.71.3/react-native-0.71.3.pom
       - https://dl.google.com/dl/android/maven2/com/facebook/react/react-native/0.71.3/react-native-0.71.3.pom
       - https://www.jitpack.io/com/facebook/react/react-native/0.71.3/react-native-0.71.3.pom
       - file:/Users/verochan/app-native/node_modules/@notifee/react-native/android/libs/com/facebook/react/react-native/0.71.3/react-native-0.71.3.pom
     Required by:
         project :app > project :react-native-interactable
         project :app > project :react-native-fs
         project :app > project :intercom_intercom-react-native
         project :app > project :notifee_react-native
         project :app > project :react-native-community_async-storage
         project :app > project :react-native-community_geolocation
         project :app > project :react-native-community_masked-view
         project :app > project :react-native-community_netinfo
         project :app > project :react-native-community_picker
         project :app > project :react-native-bootsplash
         project :app > project :react-native-config
         project :app > project :react-native-device-info
         project :app > project :react-native-get-random-values
         project :app > project :react-native-localize
         project :app > project :react-native-maps
         project :app > project :react-native-pager-view
         project :app > project :react-native-permissions
         project :app > project :react-native-safe-area-context
         project :app > project :react-native-screens
         project :app > project :react-native-sqlite-storage
         project :app > project :react-native-svg
         project :app > project :react-native-vector-icons
         project :app > project :rollbar-react-native
         project :app > project :react-native-flipper
   > Could not find com.facebook.react:react-android:.
     Required by:
         project :app > project :react-native-gesture-handler

On iOS, it's working fine. Any ideas?

RonRadtke commented 1 year ago

Same issue for me after creating a brand new project and starting to migrate all the old code over (due to too many fixes I would have had to do by hand)

bingaicao commented 1 year ago

I also encountered the same problem and fell back to 0.71.2 OK

SharvanTech5 commented 1 year ago

@bingaicao in 0.71.2 android and iOS both working fine ?

bingaicao commented 1 year ago

I'm an android, but you can try

RonRadtke commented 1 year ago

Downgrade to 0.71.2 did not do the cut for me. Still:

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not find com.facebook.react:react-android:0.71.2.
     Required by:
         project :app
   > Could not find com.facebook.react:hermes-android:0.71.2.
     Required by:
         project :app
   > Could not find com.facebook.react:react-android:0.71.2.
     Required by:
         project :app > project :react-native-firebase_app
         project :app > project :react-native-firebase_messaging
         project :app > project :react-native-picker_picker
bingaicao commented 1 year ago

@RonRadtke You can clean up the project and rebuild it to ensure that the Gradle is not in offline mode

RonRadtke commented 1 year ago

@bingaicao running a gradlew clean and rebuilding did not help. Running it via react-native start --reset-cache didn't help either

RonRadtke commented 1 year ago

After removing ththe following in android/build.gradle it worked:

...
exclusiveContent {
               filter {
                   includeGroup "com.facebook.react"
               }
               forRepository {
                   maven {
                       url "$rootDir/../node_modules/react-native/android"
                   }
               }
        }
        ...

Removing this part also makes the project build (until other errors pop up) with 0.71.3

bingaicao commented 1 year ago

After version 0.71.0, the local mode is no longer available. The global dependent version needs to be replaced online to ensure that all dependent versions are uniform

RonRadtke commented 1 year ago

@bingaicao Thanks a lot for the Information! I just assumed it is fine since cortinico said it was fine. @SharvanTech5 you have the same block in that I had to remove.

redpanda-bit commented 1 year ago

After removing ththe following in android/build.gradle it worked:

...
exclusiveContent {
               filter {
                   includeGroup "com.facebook.react"
               }
               forRepository {
                   maven {
                       url "$rootDir/../node_modules/react-native/android"
                   }
               }
        }
        ...

Removing this part also makes the project build (until other errors pop up) with 0.71.3

This worked for me also, thanks. There is only a README.md file in that directory $rootDir/../node_modules/react-native/android hence why the not found errors.

"Starting from React Native 0.71, we're not shipping the /android folder inside the React Native NPM package anymore due to sizing constraints on NPM. The Android artifacts are distributed via Maven Central." https://github.com/facebook/react-native/tree/main/android.

joaquim-manzini commented 1 year ago

This force command in android/build.gradle seems to be forcing the use of 0.71.3 but it doesn't exist at maven repo:

allprojects {
    configurations.all {
        resolutionStrategy {
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }
    ...

After commenting only the force line, it took from the version https://mvnrepository.com/artifact/com.facebook.react/react-native/0.71.0-rc.0 and finished building!

RubenPM-dev commented 1 year ago

Hi, also having this issue, I've compared the gradle files on the upgrade helper and my files and seem to be ok, still can't figure out the solution for this.

These are the build.gradle files: android/build.gradle https://raw.githubusercontent.com/react-native-community/rn-diff-purge/release/0.71.1/RnDiffApp/android/build.gradle

My file

buildscript {
    ext {

        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 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")
        classpath("de.undercouch:gradle-download-task:4.1.2")
        classpath("com.google.gms:google-services:4.3.14")
        classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files   
    }
}

allprojects {
    repositories {
        google()
    }
}

And the app/build.gradle https://raw.githubusercontent.com/react-native-community/rn-diff-purge/release/0.71.3/RnDiffApp/android/app/build.gradle

My app/build.gradle

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"

[...]

def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def pass = getPassword(System.getenv('KEYCHAIN_USER'), System.getenv('KEYCHAIN_SERVICE'))

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    namespace "com.myapp"
    defaultConfig {
        manifestPlaceholders = [appAuthRedirectScheme: 'myapp.auth']
        applicationId 'com.myapp'
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        if (project.hasProperty('RACENET_ANDROID_VERSION')) {
            versionCode RACENET_ANDROID_BUILD_NUMBER.toInteger()
            versionName RACENET_ANDROID_VERSION
        } else {
            versionCode 1
            versionName "1.1.3"
        }
        // buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
        flavorDimensions "default"
        resValue "string", "build_config_package", "com.myapp
    }

    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 {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword pass
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword pass
            }
        }
    }

    productFlavors {
        development {
            applicationId 'com.myapp'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
        }
        internaltest {
            applicationId 'com.myapp'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
        }
        firstparty {
            applicationId 'com.myapp'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
        }
        preprod {
            applicationId 'com.myapp'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
        }
        production {
            applicationId 'com.myapp'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
        }
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            debuggable false
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            // shrinkResources true
            proguardFiles ( getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" )
            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
                unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
            }
            ndk {
                debugSymbolLevel 'FULL'
            }
        }
    }

    // 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 fileTree(dir: "libs", include: ["*.jar"])
    implementation project(':react-native-inappbrowser-reborn')

    implementation project(':react-native-linear-gradient')

    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
    }

    constraints {
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
            because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
        }
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
            because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
        }
    }
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

And the settings.gradle

rootProject.name = 'myapp'
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
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')
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
include ':react-native-inappbrowser-reborn'
project(':react-native-inappbrowser-reborn').projectDir = new File(rootProject.projectDir,  '../node_modules/react-native-inappbrowser-reborn/android')
sehrish30 commented 1 year ago

apply plugin: "com.facebook.react"

add this in your build.gradle/app

cortinico commented 1 year ago

Asking again, can we get a reproducer?

lcastelnovo-atix commented 1 year ago

same issue here with react-native 0.71.4

neketsushonen commented 1 year ago

same issue here with react-native 0.71.6

rutgervanwilligen commented 1 year ago

Might be unrelated, but I had the same problem when upgrading my app from RN 0.68 to 0.71. In the end, I found out that my package.json still contained a reference to "react-native-gradle-plugin": "^0.0.7". Removing that line solved the issue for me.

nicks258 commented 1 year ago

Can someone please conclude how to solve this?

LouisMuriuki commented 1 year ago

@nicks258 for my case I am using a prebuild expo app with expo version 48.0.16 and reactnative version 0.71.7 I commented this line out allprojects { configurations.all { resolutionStrategy { // force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION } } and did this apply plugin: "com.facebook.react"

add this in your build.gradle/app

cortinico commented 1 year ago

Asking again, can we get a reproducer?

I'm closing this as we couldn't get a reproducer from anyone. This is not an issue in React Native core but in some library. Without a repro we can't even provide workarounds.

glennweb commented 1 year ago

I was upgrading to "react-native": "^0.72.0".

For me the issue was that for some reason react-native was not including the gradle plugin as a dependency. Was missing in my yarn.lock.

Manually adding yarn add react-native-gradle-plugin and yarn build and then editing settings.gradle file by adding this line:

includeBuild('../node_modules/react-native-gradle-plugin')

seemed to fix.

More info here: https://reactnative.dev/docs/next/integration-with-existing-apps?package-manager=yarn#adding-react-native-to-your-app

kunalpal-cpi commented 1 year ago

Adding this line in settings.gradle solved build issues

includeBuild('../node_modules/@react-native/gradle-plugin')

sebas21 commented 1 year ago

any solution?? I already tried everything

react-native:0.71.12

ariel-ariel-liao commented 1 year ago

@sebas21 have you solved it? I also tried everything but nothing solves the problem.

gsudhanshu commented 11 months ago

running

  1. npm start
  2. on another terminal: npx react-native run-android

solved this issue for me

lokesh12510 commented 10 months ago

I faced same issue with react-native:0.64.2

image

I edited the android/app/build.gradle file

dependencies {
...
implementation "com.facebook.react:react-native:0.64.2-4"  // Version installed see in package.json
...
}

It worked!

amadasif-dev commented 7 months ago

BUILD FAILED in 1m 47s 10 actionable tasks: 5 executed, 5 up-to-date PS F:\fapProject\android> cd.. PS F:\fapProject> npx react-native run-android info JS server already running. info Installing the app... 5 actionable tasks: 5 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

Picked up _JAVA_OPTIONS: -Xmx1024M

FAILURE: Build failed with an exception.

BUILD FAILED in 16s error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 Picked up _JAVA_OPTIONS: -Xmx1024M FAILURE: Build failed with an exception. What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'. > Could not find com.facebook.react:react-android:0.72.0. Required by: project :app > Could not find com.facebook.react:hermes-android:0.72.0. Required by: project :app 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 16s. info Run CLI with --verbose flag for more details. " am facing this issue too. Can anyone help me?

durupanya commented 6 months ago

After updating react-native 0.73 and gradle 8.3, I received the following error Could not find com.facebook.react:react-native:0.73.5

and I solved this by applying step by step from the link below as some friends explained, this error is also Plugin with id 'com.facebook.react' not found. It solves this too.

https://reactnative.dev/docs/next/integration-with-existing-apps?package-manager=yarn#adding-react-native-to-your-app


Note: After the update, you will definitely have missing files in the following files that are compatible with the new version: build.gradle, app/build.gradle, gradle.properties, settings.gradle, et.. *.gradle

Ghabriel-elias commented 3 months ago

Depois de remover o seguinte em Android/build.gradle funcionou:

...
exclusiveContent {
               filter {
                   includeGroup "com.facebook.react"
               }
               forRepository {
                   maven {
                       url "$rootDir/../node_modules/react-native/android"
                   }
               }
        }
        ...

A remoção desta parte também faz com que o projeto seja compilado (até que outros erros apareçam) com 0.71.3

thanks man, that soulved my problem. using react native 74.1