facebook / react-native

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

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. React-Native 0.72.8 #42838

Closed omerkars78 closed 7 months ago

omerkars78 commented 7 months ago

Description

I can build on ios platform succesfully. But i need to try build in android but i cant always i got the thesee errors. How can i resolve theese bugs? What went wrong:

Steps to reproduce

Java version = OpenJDK Runtime Environment Homebrew (build 17.0.9+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.9+0, mixed mode, sharing)

Node js. version = v20.9.0

My android/build.gradle =

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        kotlinVersion = "1.8.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
        playServicesVersion = "17.0.0"
        androidMapsUtilsVersion = "2.2.3"
        ndkVersion = "23.1.7779620"

    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.4.1')
        classpath 'com.google.gms:google-services:4.3.14'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {

    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com' }
        maven { url 'https://www.jitpack.io' }
        exclusiveContent {
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
        }
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup "com.facebook.react"
            }
        }

    }
}

My android/app/build.gralde =

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

import groovy.json.JsonSlurper

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

def jscFlavor = 'org.webkit:android-jsc:+'

def getVersionCodeFromNpm() {
    //  Read and parse package.json file from project root
    def inputFile = new File("$rootDir/../package.json")
    def packageJson = new JsonSlurper().parseText(inputFile.text)

    // Return the version, you can get any value this way
    return packageJson["majorVersion"]
}

def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    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'
    }

    defaultConfig {
        applicationId "com.sekizc.sporsimdi"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 1
        versionName project.hasProperty('versionName') ? project.property('versionName') : "0.0.0"
        multiDexEnabled true
        missingDimensionStrategy 'react-native-camera', 'mlkit'
        vectorDrawables.useSupportLibrary = true
    }
    dexOptions {
       javaMaxHeapSize "4g"
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            /* if (project.hasProperty('SPORSIMDI_UPLOAD_STORE_FILE')) {
                storeFile file(SPORSIMDI_UPLOAD_STORE_FILE)
                storePassword SPORSIMDI_UPLOAD_STORE_PASSWORD
                keyAlias SPORSIMDI_UPLOAD_KEY_ALIAS
                keyPassword SPORSIMDI_UPLOAD_KEY_PASSWORD
            } */
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
             if (nativeArchitectures) {
                ndk {
                    abiFilters nativeArchitectures.split(',')
                }
            }
        }

        release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
                unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
            }
        }
    }

    // applicationVariants are e.g. debug, release

}

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")
    implementation platform('com.google.firebase:firebase-bom:31.2.2')
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.facebook.fresco:animated-gif:2.6.0'

    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.2.1'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    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
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.implementation
    into 'libs'
}

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

My package.json =

{
  "name": "xxx",
  "version": "xxx",
  "majorVersion": xxx,
  "private": true,
  "currentVariant": "xxxx",
  "variants": {

  },
  "scripts": {
    "clean-project": "npx react-native-clean-project",
    "android": "npx react-native run-android",
    "ios": "react-native run-ios",
    "ios-14": "pnx react-native run-ios --simulator='iPhone 14 Pro Max'",
    "start": "npx react-native start",
    "test": "jest",
    "lint": "eslint .",
    "clean": "watchman watch-del-all",
    "postinstall": "patch-package"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.2.1",
    "@fortawesome/free-solid-svg-icons": "^6.2.1",
    "@fortawesome/react-native-fontawesome": "^0.3.0",
    "@gorhom/bottom-sheet": "^4.1.5",
    "@react-native-async-storage/async-storage": "^1.13.2",
    "@react-native-community/blur": "^3.6.0",
    "@react-native-community/datetimepicker": "^3.0.6",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/slider": "^4.1.6",
    "@react-native-firebase/analytics": "^18.6.1",
    "@react-native-firebase/app": "^18.6.1",
    "@react-native-firebase/crashlytics": "^18.6.1",
    "@react-native-firebase/messaging": "^18.6.1",
    "@react-native-masked-view/masked-view": "^0.3.0",
    "@react-native-picker/picker": "^1.16.8",
    "@react-native/metro-config": "^0.72.11",
    "@react-navigation/bottom-tabs": "^5.11.8",
    "@react-navigation/native": "^5.9.0",
    "@react-navigation/stack": "^5.14.3",
    "@types/lodash": "^4.14.202",
    "@types/react-native-snap-carousel": "^3.8.10",
    "@types/react-native-video": "^5.0.19",
    "axios": "^1.6.0",
    "geolib": "^3.3.1",
    "i18next": "^22.0.6",
    "lodash": "^4.17.20",
    "lottie-ios": "3.4.0",
    "lottie-react-native": "5.1.6",
    "moment": "^2.29.1",
    "postinstall-postinstall": "^2.1.0",
    "react": "18.2.0",
    "react-i18next": "^12.0.0",
    "react-native": "0.72.8",
    "react-native-macos": "0.72.10",
    "react-native-animatable": "^1.3.3",
    "react-native-barcode-mask": "^1.2.4",
    "react-native-blob-util": "^0.19.4",
    "react-native-calendars": "^1.1128.0",
    "react-native-circular-progress": "^1.3.6",
    "react-native-collapsible": "^1.6.0",
    "react-native-countdown-component": "^2.7.1",
    "react-native-date-picker": "^4.1.3",
    "react-native-device-info": "^10.8.0",
    "react-native-document-picker": "^9.0.1",
    "react-native-elements": "^3.2.0",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-haptic-feedback": "^1.13.1",
    "react-native-image-crop-picker": "^0.37.2",
    "react-native-image-viewing": "^0.2.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-localize": "^2.2.4",
    "react-native-maps": "0.29.3",
    "react-native-mask-input": "^1.2.2",
    "react-native-modal": "^13.0.1",
    "react-native-month-year-picker": "^1.8.1",
    "react-native-multicolor-progress-bar": "^1.0.3",
    "react-native-paper": "^5.10.4",
    "react-native-pdf": "^6.4.0",
    "react-native-picker-select": "^8.0.4",
    "react-native-progress": "^4.1.2",
    "react-native-qrcode-svg": "^6.0.6",
    "react-native-reanimated": "^2.17.0",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^3.25.0",
    "react-native-shake": "^3.5.0",
    "react-native-snackbar": "^2.2.4",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-sound": "^0.11.2",
    "react-native-svg": "^13.8.0",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-text-input-mask": "^2.0.1",
    "react-native-vector-icons": "^7.1.0",
    "react-native-video": "^5.2.1",
    "react-native-video-controls": "^2.8.1",
    "react-native-vision-camera": "^3.6.6",
    "react-native-webview": "^13.6.0",
    "react-native-week-view": "^0.9.0",
    "react-native-worklets-core": "^0.3.0",
    "react-redux": "^7.2.2",
    "redux": "^4.0.5",
    "redux-thunk": "^2.4.2",
    "vision-camera-code-scanner": "^0.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/eslint-config": "^0.72.2",
    "@react-native/metro-config": "^0.72.11",
    "@tsconfig/react-native": "^3.0.2",
    "@types/jest": "^29.4.0",
    "@types/react": "^18.0.27",
    "@types/react-native-text-input-mask": "^0.7.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.7.0",
    "babel-plugin-module-resolver": "^5.0.0",
    "eslint": "^8.54.0",
    "jest": "^29.7.0",
    "metro-react-native-babel-preset": "^0.77.0",
    "patch-package": "^8.0.0",
    "react-native-clean-project": "^4.0.1",
    "react-native-svg-transformer": "^1.3.0",
    "react-test-renderer": "18.2.0",
    "typescript": "^5.2.2"
  },
  "jest": {
    "preset": "react-native"
  }
}

React Native Version

0.72.8

Affected Platforms

Runtime - Android, Build - MacOS

Output of npx react-native info

System:
  OS: macOS 14.2.1
  CPU: (8) arm64 Apple M1
  Memory: 74.78 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.9.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.1.0
    path: /usr/local/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.11005911
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /opt/homebrew/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.8
    wanted: 0.72.8
  react-native-macos:
    installed: 0.72.10
    wanted: 0.72.10
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

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:.
     Required by:
         project :app
   > Could not find com.facebook.react:hermes-android:.
     Required by:
         project :app
   > 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 :app > project :react-native-community_geolocation
         project :app > project :react-native-community_slider
         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_messaging
         project :app > project :react-native-picker_picker

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

Reproducer

https://github.com/omerkars78

Screenshots and Videos

No response

github-actions[bot] commented 7 months 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.72.10. 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.
github-actions[bot] commented 7 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
frequencydesign commented 7 months ago

Can you confirm your ANDROID SDK location ? In the terminal echo $ANDROID_HOME should list the director. On a mac, something like /Users/[yourUsername]/Library/Android/sdk

omerkars78 commented 7 months ago

Can you confirm your ANDROID SDK location ? In the terminal echo $ANDROID_HOME should list the director. On a mac, something like /Users/[yourUsername]/Library/Android/sdk

export JAVA_HOME="/opt/homebrew/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home"

export ANDROID_HOME=~/Library/Android/sdk

export PATH="$JAVA_HOME/bin:$PATH" export PATH="$ANDROID_HOME/emulator:$PATH" export PATH="$ANDROID_HOME/tools:$PATH" export PATH="$ANDROID_HOME/tools/bin:$PATH" export PATH="$ANDROID_HOME/platform-tools:$PATH" export PATH="/opt/homebrew/bin:$PATH"

alias sail='bash vendor/bin/sail'

cortinico commented 7 months ago

My android/build.gradle =

This file is wrongly upgrade. That's how it should look like in a 0.72 project: https://github.com/facebook/react-native/blob/08fd9170fcdc7042fdcfe5f54eec71ed245d9795/packages/react-native/template/android/build.gradle#L17-L20

omerkars78 commented 7 months ago

My android/build.gradle =

This file is wrongly upgrade. That's how it should look like in a 0.72 project:

https://github.com/facebook/react-native/blob/08fd9170fcdc7042fdcfe5f54eec71ed245d9795/packages/react-native/template/android/build.gradle#L17-L20

    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath 'com.google.gms:google-services:4.3.14'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

now its looking like this but i have got a this bug again =

* 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.8.
     Required by:
         project :app
   > Could not find com.facebook.react:hermes-android:0.72.8.
     Required by:
         project :app
   > Could not find com.facebook.react:react-android:0.72.8.
     Required by:
         project :app > project :react-native-community_geolocation
         project :app > project :react-native-community_slider
         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_messaging
         project :app > project :react-native-picker_picker
tigerjiang commented 6 months ago

is there any update for this issue, I have met this question, why someone closed it?