首页 > 解决方案 > Gradle works with Android Studio but cmd script fails

问题描述

I freshly installed Android Studio and created a HelloWorld project. It works fine. But when I tried to build it via commandline gradlew script found in the project directory it first gave me the error that java is not installed.

After installing the java its now giving me the error:

FAILURE: Build failed with an exception.

  • What went wrong: Could not determine java version from '11.0.1'.

  • 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

Following image shows the java version and the command I executed:

error image

Note: I am running it on a Mac with MacOS High Sierra (10.13.6)

标签: android-studioandroid-gradle-plugingradlew

解决方案


这与我的 gradle 版本有关。我通过从侧面菜单中选择Project Structure并将 Gradle 版本设置为 4.10.2 将版本设置为最新。


推荐阅读