简体   繁体   English

'gradlew' 在 Android Studio 终端中未被识别为内部或外部命令错误

[英]'gradlew' is not recognized as an internal or external command error in Android Studio terminal

Getting error - 'gradlew' is not recognized as an internal or external command. operable program or batch file.出现错误 - 'gradlew' is not recognized as an internal or external command. operable program or batch file. 'gradlew' is not recognized as an internal or external command. operable program or batch file. inside Android Studio terminal.在 Android Studio 终端内。

Can anyone please tell why it's not recognizing gradlew谁能告诉为什么它不能识别gradlew

  1. gradlew command is available in your project directory. gradlew 命令在您的项目目录中可用。 If you are trying to run this command from somewhere else it will throw error.如果您尝试从其他地方运行此命令,则会引发错误。
  2. Also gradlew command package is automatically generated by Android studio when you create a new project.当您创建一个新项目时,Android Studio 也会自动生成 gradlew 命令包。 It will also prompt you to generate new gradle wrapper when you open the project.当您打开项目时,它还会提示您生成新的 gradle 包装器。
  3. you have to use ./gradlew instead of gradlew , if you are using Mac or Linux如果您使用的是 Mac 或 Linux,则必须使用 ./gradlew 而不是 gradlew

它位于 Android 文件夹下,因此您必须先从项目根文件夹中执行 cd Android,然后:

PS C:\code\my_app\android> ./gradlew signingReport

Assume that you app's name is video_compresser , so when you open terminal on Windows PC(because I am trying this on Windows) it shows the prompt like this.假设您的应用程序名称是video_compresser ,因此当您在 Windows PC 上打开终端时(因为我正在 Windows 上尝试此操作),它会显示如下提示。

C:\Users\Nuwan\StudioProjects\video_compresser>

If you run gradlew from here you will get the below message如果您从此处运行gradlew ,您将收到以下消息

'gradlew' is not recognized as an internal or external command,
operable program or batch file.

so you have to go to android directory by typing cd android command from terminal.所以你必须通过从终端输入cd android命令进入android目录。

then the prompt should be like this,那么提示应该是这样的,

C:\Users\Nuwan\StudioProjects\video_compresser\android>

then type gradlew followed by other commands you need and the error should be gone.然后键入gradlew ,然后键入您需要的其他命令,错误应该消失了。

尝试使用./gradle clean ./gradle assembleRelease为我工作。

Instead of the powershell, use the Windows Command Prompt to run the command.使用 Windows 命令提示符代替 powershell 来运行命令。

(This is an accidental finding. I used the visual studio code terminal to run the command gradlew assembleRelease to build the apk of a react-native project, but it outputs an error similar to above. I tried bash terminal, again failed to run. Out of curiosity, I used the Windows command prompt, then it worked. Hope this will help if other solutions are not working). (这是一个意外发现。我使用Visual Studio代码终端运行命令gradlew assembleRelease来构建一个react-native项目的apk,但它输出类似于上面的错误。我尝试了bash终端,再次无法运行。出于好奇,我使用了 Windows 命令提示符,然后它起作用了。如果其他解决方案不起作用,希望这会有所帮助)。

If you use powershell, and the gradlew file is in the terminal current work directory, try .\gradlew instead of gradlew.如果您使用 powershell,并且 gradlew 文件位于终端当前工作目录中,请尝试使用 .\gradlew 而不是 gradlew。 Powershell don't run the command in the current work directory automatically. Powershell 不会自动运行当前工作目录中的命令。

make sure you have debug.keystore file in确保你有 debug.keystore 文件
PS C:\code\my_app\android> before you run ./gradlew signingReport PS C:\code\my_app\android>在你运行之前./gradlew signingReport

ionic cordova build android --prod --release --alias=cos-android --password=abcd  --versionCode=00001 --versionName=00001 -- -- -- --packageType=bundle

cordova build android --prod --release --alias=cos-android --password=abcd  --versionCode=00001 --versionName=00001 -- -- --packageType=bundle

go to android directory by typing cd android command from terminal.通过从终端键入 cd android 命令转到 android 目录。

then the prompt should be like this, PS C:\src\offx> cd android PS C:\src\offx\android>那么提示应该是这样的, PS C:\src\offx> cd android PS C:\src\offx\android>

(//then type) ".\gradlew signinReport" PS C:\src\offx\android> .\gradlew signinReport (//然后输入) ".\gradlew signinReport" PS C:\src\offx\android> .\gradlew signinReport

Then you will get your sha keys然后你会得到你的 sha 密钥

gradlew command is only available in your project directory or gradlew file location. gradlew 命令仅在您的项目目录或 gradlew 文件位置可用。 If you are trying to run this command from somewhere else it will throw error.如果您尝试从其他地方运行此命令,则会引发错误。 so go to that particular location where gradlew file available所以去那个 gradlew 文件可用的特定位置

in vscode do this step在 vscode 中做这一步

  1. go to your project directory转到您的项目目录
  2. cd to android cd到安卓
  3. type ./gradlew in your terminal instead of gradlew在终端中输入 ./gradlew 而不是 gradlew
  4. voila, it works for windows user瞧,它适用于 Windows 用户

I am using windows OS and have to run a Java project in IntelliJ.我正在使用 Windows 操作系统,并且必须在 IntelliJ 中运行 Java 项目。 I used the command prompt in admin mode then it worked for me.我在管理员模式下使用了命令提示符,然后它对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Studio错误“ reg”无法识别为内部或外部命令 - Android Studio Error 'reg' is not recognized as an internal or external command cd android && ./gradlew assembleRelease '.' 不是内部或外部命令、可运行的程序或批处理文件 - cd android && ./gradlew assembleRelease '.' is not recognized as an internal or external command, operable program or batch file 'gradlew' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'gradlew' is not recognized as an internal or external command, operable program or batch file 'gradlew.bat' 不被识别为内部或外部命令,反应原生 - 'gradlew.bat' is not recognized as an internal or external command, react native android'无法识别为内部或外部命令 - android' is not recognized as an internal or external command android不被识别为内部或外部命令 - android is not recognized as an internal or external command Android Studio-无法将“ ndk-build”识别为内部或外部命令 - Android Studio - “ndk-build” is not a recognized as an internal or external command 在Android Studio中,adb未被识别为内部或外部命令错误 - adb is not recognized as an internal or exteral command error in Android studio android.bat无法识别为内部或外部命令 - android.bat is not recognized as an internal or external command '-v'在Android中未被识别为内部或外部命令 - '-v' is not recognized as an internal or external command in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM