Expo 项目错误:配置项目 ':expo-modules-core' 时出现问题

问题描述 投票:0回答:1

几个月前我正在开发一个项目,当时它正在工作,现在我再次克隆了存储库并执行了所有步骤,例如

npm install
然后
npx expo run:android
但我收到这个错误 即使卸载后
expo-modules-core
我也收到错误

> Configure project :expo-modules-core
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Script 'C:\Users\princ\Downloads\freelancing\prince\tradespoto-admin\node_modules\expo-modules-autolinking\scripts\android\autolinking_implementation.gradle' line: 326

* What went wrong:
A problem occurred evaluating project ':expo'.
> A problem occurred configuring project ':expo-modules-core'.
   > Failed to notify project evaluation listener.
      > SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\princ\Downloads\freelancing\prince\tradespoto-admin\android\local.properties'.
      > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo'.
> compileSdkVersion is not specified. Please add it to build.gradle

* 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 13s
10 actionable tasks: 10 up-to-date
Error: C:\Users\princ\Downloads\freelancing\prince\tradespoto-admin\android\gradlew.bat exited with non-zero code: 1
android react-native gradle expo
1个回答
0
投票

因此,此问题的主要原因是未设置 ANDROID_HOME 变量,并且 android 文件夹中也不存在 local.properties 文件。

就我个人而言,在放置 local.properties 文件后它得到修复,因为在 Windows 中,设置变量不起作用。

所以在 local.properties 文件中放入这个。

sdk.dir={path to sdk}

注意 - 如果路径显示文件夹名称为“Sdk”,但仍然仅使用“sdk”,那么只有它对我有用。

在 Mac 和 Linux 中,您可以通过设置变量来完成

对于 mac,设置为

~/.zshrc

export ANDROID_HOME=$HOME/Library/Android/sdk

对于 Linux,执行相同的方法,只是路径会更改并根据您正在使用的终端配置文件进行操作。

© www.soinside.com 2019 - 2024. All rights reserved.