facebook / react-native

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

Task with path 'bundleDebugJsAndAssets' not found in project ':app #38318

Closed antoinedelp closed 1 year ago

antoinedelp commented 1 year ago

New Version

0.72.2

Old Version

0.67.5

Build Target(s)

Android debug/release

Output of react-native info

System:
  OS: macOS 13.1
  CPU: (8) x64 Apple M2
  Memory: 16.62 MB / 16.00 GB
  Shell:
    version: 5.8.1
    path: /bin/zsh
Binaries:
  Node:
    version: 16.17.0
    path: ~/.nvm/versions/node/v16.17.0/bin/node
  Yarn:
    version: 3.5.0
    path: /usr/local/bin/yarn
  npm:
    version: 8.15.0
    path: ~/.nvm/versions/node/v16.17.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/antoinedelport/.rvm/gems/ruby-2.7.4/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK:
    API Levels:
      - "23"
      - "26"
      - "27"
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 29.0.3
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
    System Images:
      - android-30 | Google APIs Intel x86 Atom
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.1 AI-221.6008.13.2211.9514443
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 15.0.1
    path: /usr/bin/javac
  Ruby:
    version: 2.7.4
    path: /Users/antoinedelport/.rvm/rubies/ruby-2.7.4/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.2
    wanted: 0.72.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Issue and Reproduction Steps

When trying to update my react-native app to 0.72.2, I encounter this error related to the React Native Gradle Plugin:

FAILURE: Build failed with an exception.

  • What went wrong: Could not determine the dependencies of task ':app:generateBundledResourcesHashDevelopmentDebug'.

    Task with path 'bundleDevelopmentDebugJsAndAssets' not found in project ':app'.

  • Exception is: org.gradle.api.internal.tasks.TaskDependencyResolveException: Could not determine the dependencies of task ':app:generateBundledResourcesHashDevelopmentDebug'. at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:68) at org.gradle.execution.plan.TaskDependencyResolver.resolveDependenciesFor(TaskDependencyResolver.java:49) at org.gradle.execution.plan.LocalTaskNode.getDependencies(LocalTaskNode.java:147) at org.gradle.execution.plan.LocalTaskNode.resolveDependencies(LocalTaskNode.java:121) at org.gradle.execution.plan.DefaultExecutionPlan.discoverNodeRelationships(DefaultExecutionPlan.java:184) at org.gradle.execution.plan.DefaultExecutionPlan.doAddEntryNodes(DefaultExecutionPlan.java:156) at org.gradle.execution.plan.DefaultExecutionPlan.addEntryTasks(DefaultExecutionPlan.java:131) at org.gradle.execution.plan.DefaultExecutionPlan.addEntryTasks(DefaultExecutionPlan.java:123) at org.gradle.execution.TaskNameResolvingBuildTaskScheduler.scheduleRequestedTasks(TaskNameResolvingBuildTaskScheduler.java:53)

This issue occurs whether I'm activating or not hermes, and activating or now the new Architecture. The react-native Awesome project app works fine, but not ours.

I tried added all debuggable variants, switched back to a debug without flavor... still couldn't manage to make it work. I am working to reproduce the issue on a dummy project, by putting the same config than in ours. What could cause this issue? It is very hard to debug properly the gradle process.

Here is our android/app/build.gradle:

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

apply plugin: 'com.google.gms.google-services'

react {
debuggableVariants = ["debug", "developmentDebug", "stagingDebug", "productionDebug"]
}

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

// VESDK
apply plugin: 'ly.img.android.sdk'

imglyConfig {

    modules {
        include 'ui:text'
        include 'ui:focus'
        include 'ui:frame'
        include 'ui:brush'
        include 'ui:filter'
        include 'ui:sticker'
        include 'ui:overlay'
        include 'ui:transform'
        include 'ui:adjustment'
        include 'ui:text-design'
        include 'ui:video-trim'
        include 'ui:video-library'
        include 'ui:video-composition'
        include 'ui:audio-composition'

        // This module is big, remove the serializer if you don't need that feature.
        //include 'backend:serializer'

        // Remove the asset packs you don't need, these are also big in size.
        include 'assets:font-basic'
        include 'assets:frame-basic'
        include 'assets:filter-basic'
        include 'assets:overlay-basic'
        include 'assets:sticker-shapes'
        include 'assets:sticker-emoticons'
        include 'assets:sticker-animated'

        include 'backend:sticker-animated'
        include 'backend:sticker-smart'
    }
}

// import com.android.build.OutputFile

// the entry file for bundle generation. If none specified and
// "index.android.js" exists, it will be used. Otherwise "index.js" is
// default. Can be overridden with ENTRY_FILE environment variable.

// entryFile: "index.js",

/**
 * 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-intl:+'

// More info here: https://reactnative.dev/docs/react-native-gradle-plugin#debuggablevariants

android {

    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion rootProject.ext.minSdkVersion
        ndkVersion rootProject.ext.ndkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        compileSdkVersion rootProject.ext.compileSdkVersion
        versionCode 2111
        versionName "2.36.0"
        multiDexEnabled true // This is for method limit

        namespace "com.myapp"

        resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
    }

    signingConfigs {
        debug {
            storeFile file("../keystore/debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
        release {
            def propsFile = rootProject.file('keystore/keystore.properties')
            if (propsFile.exists()) {
                def props = new Properties()
                props.load(new FileInputStream(propsFile))
                storeFile = file(props['storeFile'])
                storePassword = props['storePassword']
                keyAlias = props['keyAlias']
                keyPassword = props['keyPassword']
            } 
            // if no keystore.properties file, we sign using debug config
            // needed for building releaseStaging locally
            else {
                storeFile file("../keystore/debug.keystore")
                storePassword "android"
                keyAlias "androiddebugkey"
                keyPassword "android"
            }
        }
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            debuggable true
        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    flavorDimensions "environment"
    productFlavors {
       development {
            resValue "string", "app_name", "OL-Dev"
            resValue "string", "CodePushDeploymentKey", ""
            applicationIdSuffix ".debug"
        }
        staging {
            applicationIdSuffix ".preprod"
        }
        production {
        resValue "string", "app_name", "OL"

        }
    }

    lintOptions {
        abortOnError false
        checkAllWarnings true
        disable "ContentDescription"
        disable "InvalidPackage"
        disable "SpUsage"
        disable "IconMissingDensityFolder"
        disable "SelectableText"
        disable "RtlCompat", "RtlEnabled", "RtlHardcoded", "RtlSymmetry"
        disable "UnusedAttribute"
    }
}

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"

    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}") {
        exclude group:'com.facebook.flipper'
    }

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
    // Crash on v.0.67. fixed in RN 0.68
    implementation ("androidx.appcompat:appcompat:1.3.1") {
        version {
            strictly '1.3.1'
        }
    }
    // Google dependencies
    implementation "com.google.android.gms:play-services-base:+"
    implementation "com.google.android.gms:play-services-basement:+"
    implementation "com.google.android.gms:play-services-auth:+"
    implementation "com.google.android.gms:play-services-fitness:20.0.0"

    // this fixes a crash related to PendingIntent on app targeting Android 12+
    implementation 'androidx.work:work-runtime:2.7.1'
    // OK HTTP Dependency need to be specified to avoid crash on Android 11
    implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.0"))
    implementation("com.squareup.okhttp3:okhttp")
    implementation("com.squareup.okhttp3:okhttp-urlconnection")

    implementation 'com.huawei.agconnect:agconnect-core:1.9.0.300'
    // HUAWEI Push
    implementation 'com.huawei.hms:push:6.11.0.300'

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

    // For WebP support, including animated WebP
    implementation 'com.facebook.fresco:animated-webp:2.1.0'
    implementation 'com.facebook.fresco:webpsupport:2.1.0'

    implementation 'androidx.multidex:multidex:2.0.1'

}

repositories {
    mavenCentral()
    maven {
        url "https://maven.google.com"
    }
    maven { url "https://maven.fabric.io/public" }
}

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

Thanks!

cortinico commented 1 year ago

What's the reason why you have 3 flavors an 2 build types. This ends up creating 6 build variants developmentDebug, productionDebug, productionRelease, etc...

You should probably just have 3 build types.

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            debuggable true
        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    flavorDimensions "environment"
    productFlavors {
       development {
            resValue "string", "app_name", "OL-Dev"
            resValue "string", "CodePushDeploymentKey", ""
            applicationIdSuffix ".debug"
        }
        staging {
            applicationIdSuffix ".preprod"
        }
        production {
        resValue "string", "app_name", "OL"

        }
    }

Anyway your problem is that this task:

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

Is causing your build to fail. I believe this might be related to CodePush. Are you using the latest version?

antoinedelp commented 1 year ago

Hi @cortinico , we are using 3 flavors and 2 buid types in order to be able to run our app in development on production/staging environment. This helps us debug issues encountered on the production/staging environments.

I had not updated the code-push package, thanks for pointing this out. I did so and the issue disappeared, but I am getting a new one:

Failed to install the app. Command failed with exit code 1: ./gradlew app:installDevelopmentDebug -PreactNativeDevServerPort=8081 /Users/antoinedelport/Documents/cto/ouimoveup/android/app/src/main/java/com/ouimoveup/MainApplication.java:4: error: cannot find symbol import com.facebook.react.PackageList; ^ symbol: class PackageList location: package com.facebook.react /Users.../ouimoveup/android/app/src/main/java/com/ouimoveup/MainApplication.java:15: error: package com.microsoft.codepush.react does not exist import com.microsoft.codepush.react.CodePush; ^ /Users/.../ouimoveup/android/app/src/main/java/com/ouimoveup/MainApplication.java:16: error: package org.wonday.orientation does not exist import org.wonday.orientation.OrientationActivityLifecycle; ^ /Users/.../ouimoveup/android/app/src/main/java/com/ouimoveup/MainApplication.java:31: error: cannot find symbol List<ReactPackage> packages = new PackageList(this).getPackages(); ^ symbol: class PackageList /Users/.../cto/ouimoveup/android/app/src/main/java/com/ouimoveup/MainApplication.java:43: error: cannot find symbol return CodePush.getJSBundleFile(); ^ symbol: variable CodePush /Users/.../android/app/src/main/java/com/ouimoveup/MainApplication.java:52: error: method does not override or implement a method from a supertype @Override ^ /Users/.../ouimoveup/android/app/src/main/java/com/ouimoveup/MainApplication.java:56: error: method does not override or implement a method from a supertype @Override ^ /Users/.../ouimoveup/android/app/src/main/java/com/ouimoveup/MainApplication.java:69: error: cannot find symbol ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); ^ symbol: variable ReactNativeFlipper location: class MainApplication Note: /Users/.../ouimoveup/android/app/build/generated/source/kapt/developmentDebug/ly/img/android/sdk/IMGLYEventAccessors.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

I can close this issue and create a new one if you prefer! Many thanks.

cortinico commented 1 year ago

I can close this issue and create a new one if you prefer!

Yes please 👍