Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fresh project does not build on Android #35892

Closed
BZaldua opened this issue Jan 19, 2023 · 13 comments
Closed

Fresh project does not build on Android #35892

BZaldua opened this issue Jan 19, 2023 · 13 comments
Labels
Platform: Android Android applications. Platform: Linux Building on Linux. Resolution: Answered When the issue is resolved with a simple answer

Comments

@BZaldua
Copy link

BZaldua commented Jan 19, 2023

Description

I just created a new project and as soon as I open it on Android Studio, this error is shown:

Null extracted folder for artifact: ResolvedArtifact(componentIdentifier=com.facebook.react:react-android:0.71.0, variant=com.facebook.react:react-android:0.71.0 variant debugVariantDefaultApiPublication, variantName=null, artifactFile=/MY_USER/.gradle/caches/modules-2/files-2.1/com.facebook.react/react-android/0.71.0/4760de5b8fcda11cc969ec2b872ff61b760f1433/react-android-0.71.0-debug.aar, isTestFixturesArtifact=false, extractedFolder=null, publishedLintJar=null, dependencyType=ANDROID, isWrappedModule=false, buildMapping={__current_build__=/MY_USER/PROJECT_DIR/RN71/android, react-native-gradle-plugin=//MY_USER/PROJECT_DIR/RN71/node_modules/react-native-gradle-plugin})

If I create a fresh project with 0.70.6 everything is OK, but this last version does not seem to be working

Version

0.71.0

Output of npx react-native info

System:
OS: Linux 5.4 Ubuntu 18.04.4 LTS (Bionic Beaver)
CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
Memory: 3.94 GB / 15.50 GB
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 9.3.1 - ~/.nvm/versions/node/v16.19.0/bin/npm
Watchman: Not Found
SDKs:
Android SDK:
Android NDK: 21.0.6113669
IDEs:
Android Studio: Not Found
Languages:
Java: 11.0.17 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.0 => 0.71.0
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

react-native init
cd android
./gradlew build

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

NA

@react-native-bot react-native-bot added Platform: Android Android applications. Platform: Linux Building on Linux. labels Jan 19, 2023
@cortinico
Copy link
Contributor

Null extracted folder for artifact

This often happens if your device runs out of memory.
I would suggest you give the JVM more memory.

  1. Open android/gradle.properties
  2. Change org.gradle.jvmargs= and give -Xmx4096M

@BZaldua
Copy link
Author

BZaldua commented Jan 19, 2023

Unfortunatelly keeps showing the same error. I even cleared Gradle cache but the same error is raised

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jan 19, 2023
@cortinico
Copy link
Contributor

I even cleared Gradle cache but the same error is raised

What specifically have you done?

@BZaldua
Copy link
Author

BZaldua commented Jan 19, 2023

./gradlew cleanBuildCache and just in case rm -r $HOME/.gradle/caches/

@cortinico
Copy link
Contributor

./gradlew cleanBuildCache and just in case rm -r $HOME/.gradle/caches/

In your specific case I'd try to also:

  1. cd android && ./gradlew --stop
  2. kill all the java and gradle processes
  3. rm -r $HOME/.gradle

Try to rebuild after every step. The last one is pretty disruptive and will take you quite some time to rebuild after it.

@cortinico cortinico added Needs: Author Feedback and removed Needs: Attention Issues where the author has responded to feedback. labels Jan 19, 2023
@BZaldua
Copy link
Author

BZaldua commented Jan 19, 2023

@cortinico Sadly, it's worse after running that:

> Task :app:createBundleReleaseJsAndAssets FAILED
Execution optimizations have been disabled for task ':app:createBundleReleaseJsAndAssets' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/MY_USER/PROJECT_DIR/android/app/build/generated/res/react/release'. Reason: Task ':app:mergeReleaseResources' uses this output of task ':app:createBundleReleaseJsAndAssets' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.5.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':app:createBundleReleaseJsAndAssets' (type 'BundleHermesCTask').
  - In plugin 'com.facebook.react' type 'com.facebook.react.tasks.BundleHermesCTask' property 'entryFile' specifies file '/MY_USER/PROJECT_DIR/android/index.js' which doesn't exist.
    
    Reason: An input file was expected to be present but it doesn't exist.
    
    Possible solutions:
      1. Make sure the file exists before the task is called.
      2. Make sure that the task which produces the file is declared as an input.
    
    Please refer to https://docs.gradle.org/7.5.1/userguide/validation_problems.html#input_file_does_not_exist for more details about this problem.

* 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:
java.lang.StackOverflowError (no error message)

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

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jan 19, 2023
@cortinico
Copy link
Contributor

@cortinico Sadly, it's worse after running that:

Actually the issue you were facing "Null extracted folder for artifact: ResolvedArtifact" is solved.

Now your build is failing as you have specified an entry file which doesn't exist.
Can you share your android/app/build.gradle?

@BZaldua
Copy link
Author

BZaldua commented Jan 19, 2023

I had a small error in there yes. After fixing that, everything worked as expected.
Anyway, I find it weird that I had to clear Gradle's cache and kill processes when the creation was brand new. At least it's fixed, thanks @cortinico!

@BZaldua BZaldua closed this as completed Jan 19, 2023
@cortinico cortinico added Resolution: Answered When the issue is resolved with a simple answer and removed Needs: Attention Issues where the author has responded to feedback. labels Jan 19, 2023
@aytekinsahin
Copy link

aytekinsahin commented Apr 15, 2023

hi, i have the same error. I did what you said but the error is not fixed.

Null extracted folder for artifact: ResolvedArtifact(componentIdentifier=com.facebook.react:react-native:0.71.0-rc.0, variantName=null, artifactFile=/Users/aytekinsahin/.gradle/caches/modules-2/files-2.1/com.facebook.react/react-native/0.71.0-rc.0/7a7f5a0af6ebd8eb94f7e5f7495e9d9684b4f543/react-native-0.71.0-rc.0-debug.aar, extractedFolder=null, dependencyType=ANDROID, isWrappedModule=false, buildMapping={current_build=/Users/user/Desktop/Mobile Apps/test/android}, mavenCoordinatesCache=com.android.build.gradle.internal.ide.dependencies.MavenCoordinatesCacheBuildService$Inject@36caeb78)

build.gradle (app)

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**

  • The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  • and bundleReleaseJsAndAssets).
  • These basically call react-native bundle with the correct arguments during the Android build
  • cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  • bundle directly from the development server. Below you can see all the possible configurations
  • and their defaults. If you decide to add a configuration block, make sure to add it before the
  • apply from: "../../node_modules/react-native/react.gradle" line.
  • project.ext.react = [
  • // the name of the generated asset file containing your JS bundle
  • bundleAssetName: "index.android.bundle",
  • // 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.android.js",
  • // https://reactnative.dev/docs/performance#enable-the-ram-format
  • bundleCommand: "ram-bundle",
  • // whether to bundle JS and assets in debug mode
  • bundleInDebug: false,
  • // whether to bundle JS and assets in release mode
  • bundleInRelease: true,
  • // whether to bundle JS and assets in another build variant (if configured).
  • // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  • // The configuration property can be in the following formats
  • // 'bundleIn${productFlavor}${buildType}'
  • // 'bundleIn${buildType}'
  • // bundleInFreeDebug: true,
  • // bundleInPaidRelease: true,
  • // bundleInBeta: true,
  • // whether to disable dev mode in custom build variants (by default only disabled in release)
  • // for example: to disable dev mode in the staging build type (if configured)
  • devDisabledInStaging: true,
  • // The configuration property can be in the following formats
  • // 'devDisabledIn${productFlavor}${buildType}'
  • // 'devDisabledIn${buildType}'
  • // the root of your project, i.e. where "package.json" lives
  • root: "../../",
  • // where to put the JS bundle asset in debug mode
  • jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
  • // where to put the JS bundle asset in release mode
  • jsBundleDirRelease: "$buildDir/intermediates/assets/release",
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in debug mode
  • resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in release mode
  • resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
  • // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  • // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  • // date; if you have any other folders that you want to ignore for performance reasons (gradle
  • // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  • // for example, you might want to remove it from here.
  • inputExcludes: ["android/", "ios/"],
  • // override which node gets called and with what additional arguments
  • nodeExecutableAndArgs: ["node"],
  • // supply additional arguments to the packager
  • extraPackagerArgs: []
  • ]
    */

project.ext.react = [
enableHermes: false, // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.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:+'

/**

  • Whether to enable the Hermes VM.
  • This should be set on project.ext.react and mirrored here. If it is not set
  • on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
  • and the benefits of using Hermes will therefore be sharply reduced.
    */
    def enableHermes = project.ext.react.get("enableHermes", false);

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

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.test"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    missingDimensionStrategy 'react-native-camera', 'general'
    versionCode 1
    versionName "1.0"
}
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'
    }
}
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.
        signingConfig signingConfigs.debug
        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 {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.appcompat:appcompat: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 (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} 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.compile
into 'libs'
}

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

@RajBhadania737
Copy link

i getting this error

A problem was found with the configuration of task ':app:createBundleReleaseJsAndAssets' (type 'BundleHermesCTask').

  • In plugin 'com.facebook.react' type 'com.facebook.react.tasks.BundleHermesCTask' property 'entryFile' specifies file '/Users/sid/Desktop/Lumin/LuminApp/index.js' which doesn't exist.

if you have any solution . Share me

@kishanverma26
Copy link

kishanverma26 commented Aug 29, 2023

./gradlew cleanBuildCache and just in case rm -r $HOME/.gradle/caches/

In your specific case I'd try to also:

  1. cd android && ./gradlew --stop
  2. kill all the java and gradle processes
  3. rm -r $HOME/.gradle

Try to rebuild after every step. The last one is pretty disruptive and will take you quite some time to rebuild after it.

I am also facing same issue and above solution doesn't work.

@MuhammadNasirr
Copy link

@cortinico Sadly, it's worse after running that:

> Task :app:createBundleReleaseJsAndAssets FAILED
Execution optimizations have been disabled for task ':app:createBundleReleaseJsAndAssets' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/MY_USER/PROJECT_DIR/android/app/build/generated/res/react/release'. Reason: Task ':app:mergeReleaseResources' uses this output of task ':app:createBundleReleaseJsAndAssets' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.5.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':app:createBundleReleaseJsAndAssets' (type 'BundleHermesCTask').
  - In plugin 'com.facebook.react' type 'com.facebook.react.tasks.BundleHermesCTask' property 'entryFile' specifies file '/MY_USER/PROJECT_DIR/android/index.js' which doesn't exist.
    
    Reason: An input file was expected to be present but it doesn't exist.
    
    Possible solutions:
      1. Make sure the file exists before the task is called.
      2. Make sure that the task which produces the file is declared as an input.
    
    Please refer to https://docs.gradle.org/7.5.1/userguide/validation_problems.html#input_file_does_not_exist for more details about this problem.

* 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:
java.lang.StackOverflowError (no error message)

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

@BZaldua can you tell me what is the solution of this above error?

@alainib
Copy link

alainib commented Jul 16, 2024

i had this error since few days. how to solve it please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android Android applications. Platform: Linux Building on Linux. Resolution: Answered When the issue is resolved with a simple answer
Projects
None yet
Development

No branches or pull requests

8 participants