问题
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