【react-native】0.57版本打包报错:Could not resolve all files for configuration ':app:releaseCompileClasspath

xiaoxiao2025-08-09  33

react-native版本:0.57.1

这个问题原本不是rn版本的问题,原因是0.57.1将Android SDK的版本更新到27了。

先来看下错误日志: 

> Task :app:preReleaseBuild FAILED FAILURE: Build failed with an exception. * What went wrong: Could not resolve all files for configuration ':app:releaseCompileClasspath'. > Could not find support-vector-drawable.aar (com.android.support:support-vector-drawable:27.1.1). Searched in the following locations: https://jcenter.bintray.com/com/android/support/support-vector-drawable/27.1.1/support-vector-drawable-27.1.1.aar > Could not find livedata-core.aar (android.arch.lifecycle:livedata-core:1.1.0). Searched in the following locations: https://jcenter.bintray.com/android/arch/lifecycle/livedata-core/1.1.0/livedata-core-1.1.0.aar > Could not find viewmodel.aar (android.arch.lifecycle:viewmodel:1.1.0). Searched in the following locations: https://jcenter.bintray.com/android/arch/lifecycle/viewmodel/1.1.0/viewmodel-1.1.0.aar > Could not find runtime.aar (android.arch.core:runtime:1.1.0). Searched in the following locations: https://jcenter.bintray.com/android/arch/core/runtime/1.1.0/runtime-1.1.0.aar * 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 Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings BUILD FAILED in 14s 11 actionable tasks: 1 executed, 10 up-to-date

这个是只有打包apk时才会出现的错误,需要注意两个地方来确定你的错误和我遇到的是同一类错误:

1.":app:releaseCompileClasspath";

2."com.android.support:support-vector-drawable:27.1.1"。

解决方案: 

1.修改android/build.gradle中google()方法的位置,见下方代码注释;

2.如果还不行,就升级gradle版本到4.10.1(我使用的版本,不确定别的版本是否可用)。

// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "27.0.3" minSdkVersion = 16 compileSdkVersion = 27 targetSdkVersion = 26 supportLibVersion = "27.1.1" } repositories { google() jcenter() maven { url 'https://maven.google.com/' name 'Google' } } dependencies { classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() // new mavenLocal() jcenter() maven {url "https://jitpack.io"} maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven {url "https://maven.google.com"} // google() // old } } task wrapper(type: Wrapper) { gradleVersion = '4.10.1' distributionUrl = distributionUrl.replace("bin", "all") }

 

转载请注明原文地址: https://www.6miu.com/read-5034535.html

最新回复(0)