cd android && ./gradlew assembleRelease '.' 无法识别为内部或外部命令、可执行程序或批处理文件。

7
官方的ReactJS文档建议在终端中运行以下命令来生成发布APK。
cd android && ./gradlew assembleRelease

我在执行该命令时遇到了异常:

```

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

问题是什么?
2个回答

15

对于 Windows 系统,原始命令需使用反斜杠

cd android && ./gradlew assembleRelease

谢谢,它正在工作。虽然简单但花了很多时间。 - Praveen Danagoudru
在Windows中,你只能使用cd android && gradlew assembleRelease命令。 - Leffa

4

作为解决这个问题的一部分,我发现构建React Native源代码需要以下步骤:

Windows

  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
    

"$" 通常指的是 Unix shell...你的错误提示表明你正在运行 Windows。 - OneCricketeer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接