Cannot build react-native project from Android-Studio

react native run-android
open react native project in android studio
react-native-community/cli-platform-android/native_modules gradle as it does not exist
how to run react native app in android studio
android studio react native
how to integrate react native with android studio
react native getting started
android studio build release apk

I can run my react-native project. It works fine. I have tested by running using react-native. But when I'm trying to run it with Android studio I get the following error.

*FAILURE: Build failed with an exception.
* Where:
Script 'D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 195
* What went wrong:
A problem occurred evaluating settings 'employeeMobile'.
> Unable to determine the current character, it is not a string, number, array, or object

  The current character read is 'E' with an int value of 69
  Unable to determine the current character, it is not a string, number, array, or object
  line number 1
  index number 0
  Error: EPERM: operation not permitted, scandir 'D:/EmployeeApp/EmployeeMobileAppGit/employeemobile-app/android/app/build/intermediates/signing_config/debug/out/signing-config.json'    at Object.readdirSync (fs.js:790:3)    at GlobSync._readdir (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:288:41)    at GlobSync._readdirInGlobStar (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:267:20)    at GlobSync._readdir (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:276:17)    at GlobSync._processReaddir (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:137:22)    at GlobSync._process (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:132:10)    at GlobSync._processGlobStar (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:380:10)    at GlobSync._process (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:130:10)    at GlobSync._processGlobStar (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:383:10)    at GlobSync._process (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:130:10)
  ^
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'E' with an int value of 69
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
Error: EPERM: operation not permitted, scandir 'D:/EmployeeApp/EmployeeMobileAppGit/employeemobile-app/android/app/build/intermediates/signing_config/debug/out/signing-config.json'    at Object.readdirSync (fs.js:790:3)    at GlobSync._readdir (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:288:41)    at GlobSync._readdirInGlobStar (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:267:20)    at GlobSync._readdir (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:276:17)    at GlobSync._processReaddir (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:137:22)    at GlobSync._process (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:132:10)    at GlobSync._processGlobStar (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:380:10)    at GlobSync._process (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:130:10)    at GlobSync._processGlobStar (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:383:10)    at GlobSync._process (D:\EmployeeApp\EmployeeMobileAppGit\employeemobile-app\node_modules\glob\sync.js:130:10)
^
10:38:38 AM: Task execution finished.*

My project Gradle file is as follows.

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        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")
        }
        google()
        jcenter()
    }
}

My app/Gradle file is as follows.

apply plugin: "com.android.application"
import com.android.build.OutputFile
    project.ext.react = [
    entryFile: "index.js",
    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 {
    compileSdkVersion rootProject.ext.compileSdkVersion
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
        applicationId "com.employeemobile"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        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'
        }
          release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            signingConfig signingConfigs.release
            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
            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 =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
    packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
}
dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    if (enableHermes) {
      def hermesPath = "../../node_modules/hermesvm/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)

I think it's some permission problem. Run Cmd as admin then manually delete the files:

app/android/app/build/intermediates/signing_config/debug/out/signing-config.json
app/android/app/build/intermediates/signing_config/release/out/signing-config.json

solved the problem for me

Can't build new react-native project on android · Issue #26616 , I created new react native project and I can't build on android React Also, when I run from Android Studio it shows this error: ERROR: Android  Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

Please try to downgrade gradle classpath version once

classpath 'com.android.tools.build:gradle:3.3.2'

Cannot build for android · Issue #14052 · facebook/react-native , Try to create on the android folder in your react-native project a document called local.properties and inside this file type sdk.dir=yourPathToSdk  To start building your first React Native Android app, you must: Connect to your repository service account (GitHub, Bitbucket, VSTS, Azure DevOps). Select a repository and a branch where your app lives. Choose the project's package.json that you want to build.

Are you using neact-native-firebase? i had this same exact problem, if you installed it using:

yarn add @react-native-firebase/app

try uninstalling it:

yarn remove @react-native-firebase/app

and installing using:

yarn add react-native-firebase

edit:

you might run into this issue after that:

https://github.com/invertase/react-native-firebase/issues/1588

Configure Android Project, Cannot run the Android project: Make sure you added the code snippet from the Configure Native Android Project Activity section. Make sure you followed the steps from the Configure the Facebook SDK for Android section. Make sure you set up a Facebook app and updated the AndroidManifest. xml and res/values/strings. Creating and opening your react-native project in Android studio (for Mac) Nevin Kuser. Follow. Feb 9, This page will help you install and build your first React Native app. If you already

Build and run your app, Learn how to quickly build and run your app on the Android emulator or a physical device. Android Studio sets up new projects to deploy to the Android Emulator or a For projects without native/C++ code, the Build Variants panel has two If the changes can't be applied and would cause Apply Changes to fail, Android  For that, you will need to generate an upload key. Open your app in Android Studio by browsing to the android folder of your React Native project. Navigate to the Build tab, then click on Generate signed bundle / APK. Select APK to generate release APK for your React Native Android project. Then, Click on Next.

Known issues with Android Studio and Android Gradle Plugin, We've discovered in testing that the first time you run Studio after updating, it will not This section describes known issues related to project configuration and Gradle sync. Cannot apply changes when using android:sharedUserId While using the Auto or Dual debugger to debug Java and native code, if you step into a  After linking any dependency when we build the project: Build failed with an exception Could not Compile Settings File ‘project project(':react-native-gesture

Create and edit run/debug configurations, When you first create a project, Android Studio creates a default run/debug Although you can't create new templates, you can create configurations to use similar to a Note: Android Studio 2.1.x and lower had a Native Application template,  The community has even added tools such as Expo and Create React Native App to help you quickly build React Native apps without having to touch Xcode or Android Studio! While you can write React Native apps for iOS and Android, this tutorial only covers Android. You can also check out our tutorial focused on React Native for iOS.

Comments
  • Try clearing cache on android studio and restart from file->clear cache and restart
  • Still its the same exception :(
  • whats your android studio version, you will have to have the latest to run this try updating your android studio
  • When you choose the folder to run React native in the Android studio, you should select android folder and not project folder.
  • I have the latest version of Android Studio and have opened the android folder
  • I'm not using react-native-firebase