cd android && ./gradlew assembleRelease '.' is not recognized as an internal or external command, operable program or batch file

11,177

Solution 1

For Windows you need to use backslash in the original command

cd android && ./gradlew assembleRelease

Solution 2

As a part of solving this issue for Windows, I found that the following steps are required for building React Native from source:

  1. Make sure that you have Java jdk, Android SDK and gradle installed and they are accessible as global variables. You can check it by the following command (see more How to set up the environment variable for Windows):

    java -version
    android list target
    gradle -v
    
  2. it is necessary to set up gradle environment for root/android/ directory of the project (gradlew.bat executive file and other environment files)

    gradle init
    

    Note: you need to rename or remove build.gradle file before you run gradle init. After you run gradle init, you can return build.gradle back.

  3. Create directories and file AndroidManifest.xml as it is shown below

    root\android\src\main\AndroidManifest.xml
    
  4. AndroidManifest.xml has to have the following minimal content:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="myAppName">
      <uses-permission android:name="myAppName" />
      <uses-feature android:name="feature-01" android:required="false" />
    </manifest>
    
  5. For Windows you need to use backslash in the original command

    cd android && .\gradlew assembleRelease
    
  6. You are going to find the resulted build package by this path:

    root\android\build\outputs\aar\android-release.aar
    
Share:
11,177
Roman
Author by

Roman

[email protected] +1 415 6509893 || +1 6507410014 Technology stack MERN: React, React-native, Redux, Typescript, ES6+, NodeJS, NestJS, ExpressJS, API, MongoDB, Webpack, NodeJS package creation/ building/ publishing TDD: Jest, Enzyme, Sinon, Cypress, TestCafe CD/CI: AWS CDK/ SDK, Jenkins, Bitbucket pipeline ML/AI: Keras, Tensorflow, Matplotlib, NumPy, Pandas, SciPy, PyTorch, FANN LAMP: Ubuntu, Nginx, SQL, Python +MyPy, PHP VC &amp; TM: Git, Github, Bitbucket, Gira Libs/Commons: Lodash, Antd, React.semantic-ui, DOM, HTML5, CSS3, CSS FlexBox

Updated on June 18, 2022

Comments

  • Roman
    Roman almost 2 years

    The official ReactJS documentation suggests to run the following command in the terminal for generating the release APK

    cd android && ./gradlew assembleRelease
    

    I get an exception in response to this command:

    cd android && ./gradlew assembleRelease '.' is not recognized as an internal or external command, operable program or batch file.
    

    What is an issue?

  • OneCricketeer
    OneCricketeer about 6 years
    The $ commonly refers to a Unix shell... Your error indicates you're running Windows
  • Praveen Danagoudru
    Praveen Danagoudru about 4 years
    Thanks, it's working. simple but took a lot of time.