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

[CXX1405] error when building with cmake #34871

Closed
alfredarcifa opened this issue Oct 5, 2022 · 36 comments
Closed

[CXX1405] error when building with cmake #34871

alfredarcifa opened this issue Oct 5, 2022 · 36 comments
Labels
Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@alfredarcifa
Copy link

alfredarcifa commented Oct 5, 2022

Description

Hi RN community,

I have an issue with ANDROID STUDIO when I try to build my app with new arch.
Below is the error.
Before I run:

./gradlew --stop
rm -rf ~/.gradle/caches/
[CXX1405] error when building with cmake using /Users/myuser/Projects/myproject/android/app/src/main/jni/CMakeLists.txt: Build command failed.
Error while executing process /Users/myuser/Library/Android/sdk/cmake/3.18.1/bin/cmake with arguments {-H/Users/myuser/Projects/myproject/android/app/src/main/jni -DCMAKE_SYSTEM_NAME=Android -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_SYSTEM_VERSION=24 -DANDROID_PLATFORM=android-24 -DANDROID_ABI=x86 -DCMAKE_ANDROID_ARCH_ABI=x86 -DANDROID_NDK=/Users/myuser/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_ANDROID_NDK=/Users/myuser/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_TOOLCHAIN_FILE=/Users/myuser/Library/Android/sdk/ndk/21.4.7075529/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/Users/myuser/Library/Android/sdk/cmake/3.18.1/bin/ninja -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/myuser/Projects/myproject/android/app/build/intermediates/cxx/Debug/d144l2h3/obj/x86 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/myuser/Projects/myproject/android/app/build/intermediates/cxx/Debug/d144l2h3/obj/x86 -DCMAKE_BUILD_TYPE=Debug -B/Users/myuser/Projects/myproject/android/app/.cxx/Debug/d144l2h3/x86 -GNinja -DPROJECT_BUILD_DIR=/Users/myuser/Projects/myproject/android/app/build -DREACT_ANDROID_DIR=/Users/myuser/Projects/myproject/android/../node_modules/react-native/ReactAndroid -DREACT_ANDROID_BUILD_DIR=/Users/myuser/Projects/myproject/android/../node_modules/react-native/ReactAndroid/build -DNODE_MODULES_DIR=/Users/myuser/Projects/myproject/android/../node_modules -DANDROID_STL=c++_shared}
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/myuser/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/myuser/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done

CMake Error in CMakeLists.txt:
  Imported target "fbjni" includes non-existent path

    "/Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/src/main/jni/first-party/fbjni/headers"

CMake Error in CMakeLists.txt:
Imported target "fbjni" includes non-existent path

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.



CMake Warning:
  Manually-specified variables were not used by the project:

    NODE_MODULES_DIR


CMake Generate step failed.  Build files cannot be regenerated correctly.

CMake Warning:
Manually-specified variables were not used by the project:

C/C++: prefabUsage: prefab [OPTIONS] PACKAGE_PATH...
C/C++: prefabError: Invalid value for "PACKAGE_PATH": Directory "/Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/hermes-engine/build/intermediates/prefab_package_configuration/debug/prefab" is not readable.
[CXX1405] error when building with cmake using /Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/src/main/jni/CMakeLists.txt: Build command failed.
Error while executing java process with main class com.google.prefab.cli.AppKt with arguments {--build-system cmake --platform android --abi x86 --os-version 21 --stl c++_shared --ndk-version 21 --output /Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/.cxx/Debug/3q5b1z6p/prefab/x86/prefab-configure /Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/hermes-engine/build/intermediates/prefab_package_configuration/debug/prefab}

Usage: prefab [OPTIONS] PACKAGE_PATH...

Error: Invalid value for "PACKAGE_PATH": Directory "/Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/hermes-engine/build/intermediates/prefab_package_configuration/debug/prefab" is not readable.

Invalid value for "PACKAGE_PATH": Directory "/Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/hermes-engine/build/intermediates/prefab_package_configuration/debug/prefab" is not readable.

[CXX1400] Gradle project cmake.path is /Users/myuser/Projects/myproject/node_modules/react-native/sdks/hermes/CMakeLists.txt but that file doesn't exist
C/C++: debug|x86 :CMake Error: The source directory "/Users/myuser/Projects/myproject/node_modules/react-native/sdks/hermes" does not exist.
C/C++: debug|x86 :Specify --help for usage, or press the help button on the CMake GUI.
[CXX1405] error when building with cmake using /Users/myuser/Projects/myproject/node_modules/react-native/sdks/hermes/CMakeLists.txt: Build command failed.
Error while executing process /Users/myuser/Library/Android/sdk/cmake/3.18.1/bin/cmake with arguments {-H/Users/myuser/Projects/myproject/node_modules/react-native/sdks/hermes -DCMAKE_SYSTEM_NAME=Android -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_SYSTEM_VERSION=21 -DANDROID_PLATFORM=android-21 -DANDROID_ABI=x86 -DCMAKE_ANDROID_ARCH_ABI=x86 -DANDROID_NDK=/Users/myuser/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_ANDROID_NDK=/Users/myuser/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_TOOLCHAIN_FILE=/Users/myuser/Library/Android/sdk/ndk/21.4.7075529/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/Users/myuser/Library/Android/sdk/cmake/3.18.1/bin/ninja -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/hermes-engine/build/intermediates/cxx/Release/55n4523v/obj/x86 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/hermes-engine/build/intermediates/cxx/Release/55n4523v/obj/x86 -DCMAKE_FIND_ROOT_PATH=/Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/hermes-engine/.cxx/Release/55n4523v/prefab/x86/prefab -B/Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/hermes-engine/.cxx/Release/55n4523v/x86 -GNinja -DHERMES_IS_ANDROID=True -DANDROID_STL=c++_shared -DANDROID_PIE=True -DANDROID_LD=lld -DIMPORT_HERMESC=/Users/myuser/Projects/myproject/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/ImportHermesc.cmake -DJSI_DIR=/Users/myuser/Projects/myproject/node_modules/react-native/ReactCommon/jsi -DHERMES_SLOW_DEBUG=False -DHERMES_BUILD_SHARED_JSI=True -DHERMES_RELEASE_VERSION=for RN 0.70.2 -DHERMES_ENABLE_INTL=True -DCMAKE_BUILD_TYPE=Release}

CMake Error: The source directory "/Users/myuser/Projects/myproject/node_modules/react-native/sdks/hermes" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

CMake Error: The source directory "/Users/myuser/Projects/myproject/node_modules/react-native/sdks/hermes" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

Version

0.70.2

Output of npx react-native info

System:
OS: macOS 12.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 353.41 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.6.0 - ~/.nvm/versions/node/v18.6.0/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v18.6.0/bin/npm
Watchman: 2022.09.26.00 - /usr/local/bin/watchman
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
Android SDK:
API Levels: 29, 30, 31
Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0
System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64, android-31 | Google Play Intel x86 Atom_64
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8512546
Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
Languages:
Java: javac 19 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.2 => 0.70.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Android Studio > Build > Clean Project
Android Studio > Build > Refresh Linked C++ Project ( I have an issue CMake Error in CMakeLists.txt: Imported target "fbjni" includes non-existent path)

Android Studio > Build > Build Project > [CXX1405] error when building with cmake

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

android/gradle.properties

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.164.0

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=true

disableMultipleInstancesCheck=true

android/app/proguard-rules.pro

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:
-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }

android/app/src/main/jni/CMakeLists.txt

cmake_minimum_required(VERSION 3.13)

# Define the library name here.
project(myproject_appmodules)

# This file includes all the necessary to let you build your application with the New Architecture.
include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)
@alfredarcifa alfredarcifa added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Oct 5, 2022
@cortinico
Copy link
Contributor

0.72.1

Can you clarify which version of React Native are you using?

@cortinico
Copy link
Contributor

Also can you please share your android/build.gradle and android/app/build.gradle

@alfredarcifa
Copy link
Author

0.72.1

Can you clarify which version of React Native are you using?

Hi Nicola,

0.70.2

@alfredarcifa
Copy link
Author

Also can you please share your android/build.gradle and android/app/build.gradle

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

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 25
        compileSdkVersion = 31
        targetSdkVersion = 31

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.2.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:5.0.1")
        // NOTE: 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'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
    }
}

allprojects {
    repositories {
        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"
            }
        }
        google()
        maven { url 'https://www.jitpack.io' }
    }
}

android/app/build.gradle

apply plugin: "com.android.application"
apply plugin: "com.google.gms.google-services" // Google services Gradle plugin
apply plugin: 'com.google.firebase.crashlytics'
import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os

/**
 * 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: true,  // 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 that value will be read 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);

/**
 * Architectures to build native code for.
 */
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

    defaultConfig {
        applicationId "com.myproject"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

        if (isNewArchitectureEnabled()) {
            // We configure the CMake build only if you decide to opt-in for the New Architecture.
            externalNativeBuild {
                cmake {
                    arguments "-DPROJECT_BUILD_DIR=$buildDir",
                        "-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
                        "-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
                        "-DNODE_MODULES_DIR=$rootDir/../node_modules",
                        "-DANDROID_STL=c++_shared"
                }
            }
            if (!enableSeparateBuildPerCPUArchitecture) {
                ndk {
                    abiFilters (*reactNativeArchitectures())
                }
            }
        }
    }

    if (isNewArchitectureEnabled()) {
        // We configure the NDK build only if you decide to opt-in for the New Architecture.
        externalNativeBuild {
            cmake {
                path "$projectDir/src/main/jni/CMakeLists.txt"
            }
        }
        def reactAndroidProjectDir = project(':ReactAndroid').projectDir
        def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
            dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
            from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
            into("$buildDir/react-ndk/exported")
        }
        def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
            dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
            from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
            into("$buildDir/react-ndk/exported")
        }
        afterEvaluate {
            // If you wish to add a custom TurboModule or component locally,
            // you should uncomment this line.
            // preBuild.dependsOn("generateCodegenArtifactsFromSchema")
            preDebugBuild.dependsOn(packageReactNdkDebugLibs)
            preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)

            // Due to a bug inside AGP, we have to explicitly set a dependency
            // between configureCMakeDebug* tasks and the preBuild tasks.
            // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
            configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
            configureCMakeDebug.dependsOn(preDebugBuild)
            reactNativeArchitectures().each { architecture ->
                tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
                    dependsOn("preDebugBuild")
                }
                tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
                    dependsOn("preReleaseBuild")
                }
            }
        }
    }

    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('myproject_UPLOAD_STORE_FILE')) {
                        storeFile file(myproject_UPLOAD_STORE_FILE)
                        storePassword myproject_UPLOAD_STORE_PASSWORD
                        keyAlias myproject_UPLOAD_KEY_ALIAS
                        keyPassword myproject_UPLOAD_KEY_PASSWORD
                    }
                }
    }
    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.
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release // .debug
        }
    }

    // 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 {
    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:30.3.0')
    // Add the dependency for the Firebase SDK for Google Analytics
    // When using the BoM, don't specify versions in Firebase dependencies
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.firebase:firebase-perf'

    // Add the dependencies for any other desired Firebase products
    // https://firebase.google.com/docs/android/setup#available-libraries
    implementation 'com.google.firebase:firebase-iid'
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.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) {
        //noinspection GradleDynamicVersion
        implementation("com.facebook.react:hermes-engine:+") { // From node_modules
            exclude group:'com.facebook.fbjni'
        }
    } else {
        implementation jscFlavor
    }

    implementation 'com.google.android.gms:play-services-tagmanager:18.0.1'
        implementation project(':react-native-exception-handler')
}

if (isNewArchitectureEnabled()) {
    // If new architecture is enabled, we let you build RN from source
    // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
    // This will be applied to all the imported transtitive dependency.
    configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute(module("com.facebook.react:react-native"))
                    .using(project(":ReactAndroid"))
                    .because("On New Architecture we're building React Native from source")
            substitute(module("com.facebook.react:hermes-engine"))
                    .using(project(":ReactAndroid:hermes-engine"))
                    .because("On New Architecture we're building Hermes from source")
        }
    }
}

// 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)

def isNewArchitectureEnabled() {
    // To opt-in for the New Architecture, you can either:
    // - Set `newArchEnabled` to true inside the `gradle.properties` file
    // - Invoke gradle with `-newArchEnabled=true`
    // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
    return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}


@cortinico
Copy link
Contributor

Your config seems correct.
Can you try to reproduce on a empty project?

@avegrv
Copy link

avegrv commented Oct 11, 2022

Fixed with updating
com.android.tools.build:gradle
from
7.2.2
to
7.3.0

🤷

@cortinico @alfredarcifa

@sebasg0
Copy link

sebasg0 commented Oct 12, 2022

Hi @cortinico , I got same issue in 70.3. Any fix for this? as bumping the com.android.tools.build:gradle didn't worked for me

@cortinico cortinico added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Oct 14, 2022
@github-actions
Copy link

⚠️ Missing Reproducible Example
ℹ️ 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
Copy link
Contributor

@sebasg0 @avegrv Please provide a minimal reproducer and we can look into this. I just checked on 0.70.3 and this issue doesn't reproduce on my machine on a empty project.

@alfredarcifa
Copy link
Author

Fixed with updating com.android.tools.build:gradle from 7.2.2 to 7.3.0

🤷

@cortinico @alfredarcifa

Are you sure?
If I set 7.3.0 in build.gradle I receive an error console:

A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.version-check'.
   > Minimum supported Gradle version is 7.4. Current version is 7.3.3. If using the gradle wrapper, try editing the distributionUrl in /Users/user/Projects/project/android/gradle/wrapper/gradle-wrapper.properties to gradle-7.4-all.zip

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Oct 25, 2022
@lukeqsun
Copy link

lukeqsun commented Nov 8, 2022

I had the same issue on Windows 10.
Fixed by uninstalling the cmake from the system path.

@bondar-denys
Copy link

I upped the com.android.tools.build:gradle like suggested in this comment:

Fixed with updating com.android.tools.build:gradle from 7.2.2 to 7.3.0

But faced another issue. While trying to resolve that new issue I stumbled across this thread and a comment

After applying changes from that thread to my build.gradle file the build finally worked for me.
Then I reverted the com.android.tools.build:gradle change back, and the build still worked

@sssajjad007
Copy link

I had the same issue on Windows 10. Fixed by uninstalling the cmake from the system path.

How did you do this?

@quadratoms
Copy link

I had the same issue on Windows 10. Fixed by uninstalling the cmake from the system path.

this works for me

windows 11

@jovanialferez
Copy link

jovanialferez commented Dec 14, 2022

what works with me on M1 mac was by opening AS from terminal like this: open -a /Applications/Android\ Studio.app

i am using iTerm2 and not in Rosetta

@srxffcc1
Copy link

srxffcc1 commented Jan 5, 2023

For windows. You need to install the c++runtime.This works for me.
Dingtalk_20230105094928

@cortinico
Copy link
Contributor

This and a lot of other C++ build failures where fixed on 0.71
Can you try again on 0.71 and report if the issue persists?

@znakeeye
Copy link

znakeeye commented Jan 18, 2023

Could this be related? https://issuetracker.google.com/issues/175291074

prefab doesn't seem too happy when interfering with its tasks :(

@cortinico
Copy link
Contributor

Could this be related? issuetracker.google.com/issues/175291074

Nope that's not related

@Dat-Mobile
Copy link

+1. Same for me

Got the error on "react-native": "0.71.2" with newArchEnabled=true

android/build.gradle: classpath("com.android.tools.build:gradle:7.3.1")

I don't have this path in my project: android/app/src/main/jni/CMakeLists.txt

@cortinico
Copy link
Contributor

I'm closing as @alfredarcifa is unresponsive.
This and other build failures for New Architecture in 0.70 have been fixed in 0.71

If you're still seeing similar issues like this one (e.g. as @Dat-Mobile mentioned), open a new issue and provide a reproducer.

@cortinico cortinico removed Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Attention Issues where the author has responded to feedback. labels Feb 20, 2023
@krmao
Copy link

krmao commented Apr 12, 2023

for win11, cmake build error, found the solution

set GRADLE_USER_HOME D:\Cache\.gradle to system path for cmake build if user name is Chinese https://stackoverflow.com/questions/28838699/how-to-set-gradle-cache-location

@Gijuno
Copy link

Gijuno commented Jun 5, 2023

I just removed .cxx folder in ./android/app/.
I worked but I don't know the reason. (I just think removing the cache file is the only way.)
Can anybody explain this?

If doesn't work, remove ./android/app/build folder too

@SoorajChoudhary
Copy link

Same issue, Please give me solution .

@lfabl
Copy link

lfabl commented Jul 7, 2023

You must only install C++ sdk to your pc.

For x64: here
For x86: here

and do the following processes respectively:

  • delete node_modules directory.
  • delete android/build directory.
  • delete android/.gradle directory.
  • delete android/app/build directory
    then
  • run "yarn" command.
  • run "yarn ios" or "yarn android" command. ( run the project. )

@AkanshaMundel
Copy link

I had the same issue on Windows 10. Fixed by uninstalling the cmake from the system path.

How did you do this?

hey did u find any solution ?

@sssajjad007
Copy link

I just cleared all the cache,

path on windows: C:\Users\xxx.gradle\

@AkanshaMundel
Copy link

I just cleared all the cache,

path on windows: C:\Users\xxx.gradle\

hey , tried with that too but still getting this > [CXX1428] exception while building Json A problem occurred starting process 'command 'C:\Users\hp\AppData\Local\Android\Sdk\cmake\3.22.1\bin\cmake.exe'' , any other way? to get resolved from this

@AkanshaMundel
Copy link

I had the same issue on Windows 10. Fixed by uninstalling the cmake from the system path.

this works for me

windows 11

hey how did you find the cmake system path?

@znakeeye
Copy link

Maybe related to very long paths? Try enabling long paths or move the project to e.g. C:\src\

@buithanhnhan76
Copy link

You must only install C++ sdk to your pc.

For x64: here For x86: here

and do the following processes respectively:

  • delete node_modules directory.
  • delete android/build directory.
  • delete android/.gradle directory.
  • delete android/app/build directory
    then
  • run "yarn ios" or "yarn android" command. ( run the project. )

This way work for me!, thanks a lot

@heyakhil
Copy link

I just cleared all the cache,
path on windows: C:\Users\xxx.gradle\

hey , tried with that too but still getting this > [CXX1428] exception while building Json A problem occurred starting process 'command 'C:\Users\hp\AppData\Local\Android\Sdk\cmake\3.22.1\bin\cmake.exe'' , any other way? to get resolved from this

uninstall cmake and reinstall it

@krmao
Copy link

krmao commented Oct 26, 2023

I am reinstsall windows system with new english words user name and build success

@SoorajChoudhary
Copy link

@AkanshaMundel thanks. It's working fine.

@Rajkdea123
Copy link

[CXX1429] error when building with cmake using C:\Users\ry042\OneDrive\Desktop\gitp\Android_2\httpsupgrade\httpsupgrade-impl\CMakeLists.txt: -- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/ry042/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/ry042/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done

C++ build system [configure] failed while executing:
@echo off
"C:\Users\ry042\AppData\Local\Android\Sdk\cmake\3.22.1\bin\cmake.exe" ^
"-HC:\Users\ry042\OneDrive\Desktop\gitp\Android_2\httpsupgrade\httpsupgrade-impl" ^
"-DCMAKE_SYSTEM_NAME=Android" ^
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" ^
"-DCMAKE_SYSTEM_VERSION=23" ^
"-DANDROID_PLATFORM=android-23" ^
"-DANDROID_ABI=x86_64" ^
"-DCMAKE_ANDROID_ARCH_ABI=x86_64" ^
"-DANDROID_NDK=C:\Users\ry042\AppData\Local\Android\Sdk\ndk\21.4.7075529" ^
"-DCMAKE_ANDROID_NDK=C:\Users\ry042\AppData\Local\Android\Sdk\ndk\21.4.7075529" ^
"-DCMAKE_TOOLCHAIN_FILE=C:\Users\ry042\AppData\Local\Android\Sdk\ndk\21.4.7075529\build\cmake\android.toolchain.cmake" ^
"-DCMAKE_MAKE_PROGRAM=C:\Users\ry042\AppData\Local\Android\Sdk\cmake\3.22.1\bin\ninja.exe" ^
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\ry042\OneDrive\Desktop\gitp\Android_2\httpsupgrade\httpsupgrade-impl\build\intermediates\cxx\Debug\73243a72\obj\x86_64" ^
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=C:\Users\ry042\OneDrive\Desktop\gitp\Android_2\httpsupgrade\httpsupgrade-impl\build\intermediates\cxx\Debug\73243a72\obj\x86_64" ^
"-DCMAKE_BUILD_TYPE=Debug" ^
"-BC:\Users\ry042\OneDrive\Desktop\gitp\Android_2\httpsupgrade\httpsupgrade-impl\.cxx\Debug\73243a72\x86_64" ^
-GNinja
from C:\Users\ry042\OneDrive\Desktop\gitp\Android_2\httpsupgrade\httpsupgrade-impl
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as

project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Error at CMakeLists.txt:13 (add_library):
Cannot find source file:

src/main/cpp/bloom_cpp/src/BloomFilter.cpp

Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
.hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc

CMake Error at CMakeLists.txt:13 (add_library):
No SOURCES given to target: https-bloom-lib

CMake Generate step failed. Build files cannot be regenerated correctly.
-Any idea about this error

@PaulHryn
Copy link

PaulHryn commented Mar 4, 2024

I just cleared all the cache,
path on windows: C:\Users\xxx.gradle\

hey , tried with that too but still getting this > [CXX1428] exception while building Json A problem occurred starting process 'command 'C:\Users\hp\AppData\Local\Android\Sdk\cmake\3.22.1\bin\cmake.exe'' , any other way? to get resolved from this

Hey, did you solved it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests