Gradle-user guide-Installing-第四章 安装Gradle(译)

本文详细介绍如何安装Gradle,包括所需的前提条件、下载、解包、环境变量设置及测试安装是否成功的方法。此外还介绍了如何通过环境变量配置Gradle的JVM选项。

第四章 安装Gradle

4.1前提条件

Gradle 需要安装JDK 或者 JRE ,需要Java版本6或者更高。Gradle有自己的Groovy库,因此不需要另外安装Groovy,任何已经安装的Groovy都会被Gradle忽略。

4.2 下载

直接从官方网站下载。

4.3解包

从官方网站下载一个zip包,这个zip包中包含:

1.Gradle二进制文件。

2.用户手册(HTMLPDF

3.DSL参考手册

4.API文档(Javadoc Groovydoc

5.许多范例

6.源码文件

4.4环境变量

运行Gradle,需要在PATH环境变量中增加GRADLE_HOME/bin路径。

4.5运行和测试安装

可以通过使用gradle命令来运行Gradlegradle -v命令可以用来测试Gradle是否是正确安装,该命令会输出Gradle的版本号,以及本地的环境配置(groovyJVM版本等)。

4.6 JVM选项

GradleJVM选项可以通过环境变量来设置,使用GRADLE_OPTS 或者JAVA_OPTS也可以同时使用这两个变量,JAVA_OPTS会被Java应用项目共享。

一个典型的用法是,在JAVA_OPTS 中设置HTTP代理,在GRADLE_OPTS中设置内存选项。这些变量也可以在gradle和 gradlew脚本的开头设置。

pnpx react-native run-android info A dev server is already running for this project on port 8081. * daemon not running; starting now at tcp:5037 * daemon started successfully info Launching emulator... info Successfully launched emulator. info Installing the app... [Incubating] Problems report is available at: file:///D:/vue3/Yunsuo/android/build/reports/problems/problems-report.html Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.14.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor FAILURE: Build failed with an exception. * Where: Settings file 'D:\vue3\Yunsuo\android\settings.gradle' line: 2 * What went wrong: Error resolving plugin [id: 'com.facebook.react.settings'] > A problem occurred configuring project ':gradle-plugin'. > Could not resolve all artifacts for configuration 'classpath'. > Could not download kotlin-gradle-plugin-2.1.20-gradle85.jar (org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.20) > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/2.1.20/kotlin-gradle-plugin-2.1.20-gradle85.jar'. > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/2.1.20/kotlin-gradle-plugin-2.1.20-gradle85.jar'. Received status code 400 from server: Bad Request > Could not download kotlinx-coroutines-core-jvm-1.8.0.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.0) > Could not get
07-17
> react-native run-android info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 1715 file(s) to forward-jetify. Using 12 workers... info JS server already running. info Installing the app... Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings 6 actionable tasks: 6 up-to-date FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':jcore-react-native'. > Could not determine the dependencies of null. > Could not resolve all task dependencies for configuration ':jcore-react-native:classpath'. > Could not find com.android.tools.build:gradle:2.2.3. Searched in the following locations: - https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :jcore-react-native * 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 BUILD FAILED in 17s error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':jcore-react-native'. > Could not determine the dependencies of null. > Could not resolve all task dependencies for configuration ':jcore-react-native:classpath'. > Could not find com.android.tools.build:gradle:2.2.3. Searched in the following locations: - https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :jcore-react-native * 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 BUILD FAILED in 17s at makeError (D:\AwesomeProject\node_modules\execa\index.js:174:9) at D:\AwesomeProject\node_modules\execa\index.js:278:16 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async runOnAllDevices (D:\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5) at async Command.handleAction (D:\AwesomeProject\node_modules\@react-native-community\cli\build\index.js:192:9) info Run CLI with --verbose flag for more details.
08-09
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值