本文介绍了./gradlew assembleRelease构建在更新以响应本机59.8及更高版本时失败.升级到5.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将react-native更新为59.8并将gradle更新为5.1之前,我可以使用./gradlew assembleRelease进行构建.当我将本机更新为59.8,并将gradle升级为5.1时,出现以下错误

Before updating react-native to 59.8 and gradle to 5.1, I can take build using ./gradlew assembleRelease. When I updated react native to 59.8 and gradle to 5.1, I got following error

 * What went wrong:
Execution failed for task ':react-native-app-settings:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  \node_modules\react-native-app-settings\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  \node_modules\react-native-app-settings\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  \node_modules\react-native-app-settings\android\build\intermediates\res\merged\release\values\values.xml:2714: error: resource android:attr/fontVariationSettings not found.
  \node_modules\react-native-app-settings\android\build\intermediates\res\merged\release\values\values.xml:2715: error: resource android:attr/ttcIndex not found.
  error: failed linking references.

但是,如果我使用 ./gradlew bundleRelease ,则gradle将成功构建aab文件.该问题仅发生在 ./gradlew assembleRelease 上.如何生成apk文件?以下是我的Gradle设置

But If I use ./gradlew bundleRelease the gradle successfully building the aab file. the problem only happening on ./gradlew assembleRelease. How can I generate an apk file? below is my gradle settings

     dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
}

//

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

//

 ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 19
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}

推荐答案

我有相同的错误.我只是将 ./gradlew assembleRelease 替换为 ./gradlew app:assembleRelease .你应该尝试.

I had the same error. I just replaced ./gradlew assembleRelease to ./gradlew app:assembleRelease. You should try.

编辑:还有另一种方法.经过一番研究,我发现这段代码 subprojects {subproject->afterEvaluate {if((subproject.plugins.hasPlugin('android')|| subproject.plugins.hasPlugin('android-library'))){android {compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion}}}}将其放在EXT中android/gladle中.并且您将能够保持 ./gradlew assembleRelease

EDIT: There's another way. After some research, I found this code subprojects { subproject -> afterEvaluate{ if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) { android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion } } } } Put it before EXT In android/gladle. And you'll be able to keep ./gradlew assembleRelease

问题是与依赖项中的buildtools与android项目中的buildtools冲突

The problem was conflict with buildtools from dependencies vs buildtools from android project

这篇关于./gradlew assembleRelease构建在更新以响应本机59.8及更高版本时失败.升级到5.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 18:48