【发布时间】:2021-05-14 05:02:24
【问题描述】:
无法在 android studio 中构建 react 原生应用。 我试过了:
- 使用 Gradle 文件同步项目,但我不能这样做,因为 错误
- 文件 -> 使缓存无效/重新启动
- 从 $HOME/.gradle 清除缓存
- 删除$HOME/.gradle
- 在 2.3.0 上更改 com.android.tools.build:gradle 版本,因为它是
此列表中的最新版本
(https://repo.jfrog.org/artifactory/libs-release-bintray/com/android/tools/build/gradle/),但是当我使用
npx react-native init projectName时,使用的是 Android 插件版本 4.1.2,但此列表中没有此版本。 也知道 Gradle、Android Gradle Plugin 的区别, Gradle Wrapper,已阅读 https://developer.android.google.cn/studio/releases/gradle-plugin?hl=en。我尝试使用最新的 Gradle v. 6.8.2 和 Android Gradle Plugin v. 4.1.2,也没有帮助构建项目。 - 更改
distributionUrl项目名称/android/gradle/wrapper/gradle-wrapper.properties - 更改文件->设置->构建、执行、部署->Gradle 使用 从指定位置 Gradle 并设置 C:/Gradle/gradle-6.8.2,它没有帮助并将其保留为默认值 我知道在 stackoverflow 和 github 上有完全相同的问题,但解决方案没有帮助。
构建输出:
Could not find com.android.tools.build:gradle:4.1.1.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.1/gradle-4.1.1.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 :react-native-settings
Add google Maven repository and sync project
Open File
现在使用:
-
Gradle v. 6.5
-
Android Gradle 插件 v. 4.1.2
-
gradle-wrapper 6.5-all
-
Android Studios 4.1.2
-
Android SDK 平台:Android 10、9、8.1、8.0、7.1.1、7.0
【问题讨论】:
标签: react-native android-studio gradle android-gradle-plugin build.gradle