./gradlew assembleRelease build failing when updated to react native 59.8 & gradle to 5.1

只谈情不闲聊 提交于 2021-02-11 15:31:35

问题


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.

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"
}

回答1:


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

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

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



来源:https://stackoverflow.com/questions/56380373/gradlew-assemblerelease-build-failing-when-updated-to-react-native-59-8-grad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!