7

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?

Roman
  • 19,236
  • 15
  • 93
  • 97

2 Answers2

15

For Windows you need to use backslash in the original command

cd android && ./gradlew assembleRelease
MAhipal Singh
  • 4,745
  • 1
  • 42
  • 57
Ah Bo
  • 173
  • 1
  • 6
4

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
    
Roman
  • 19,236
  • 15
  • 93
  • 97