简体   繁体   中英

Not able to build the release build in react native android

Task:react-native-device-information:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':react-native-device-information:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade 1 exception was raised by workers: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed C:\Users\navee.gradle\caches\transforms-2\files-2.1\bad4888d8074cc6f9c866f449fedf067\appcompat-1.0.2\res\values-v26\values-v26.xml:5:5-8:13: AAPT: error: resource android:attr/colorError not found.

You have values for compileSdkVersion which are clashing in your MY_PROJECT_NAME/build.gradle file.

The first value you have looks something like this:

android {

    compileSdkVersion 27

and further down you have some dependencies which are using/need a HIGHER compileSdkVersion value.

SOLUTION: Try using the newest SDK, 29 as of this answer. Edit your project/build.gradle (although instead of project you will have a folder named for your specific React Native project/app).

android {
    compileSdkVersion 29

    defaultConfig {
        targetSdkVersion 29
    }
    ...
}

I got this information here: https://developer.android.com/about/versions/10/setup-sdk#update-build

Explanation: If some package/dependency you're using needs to be able to use certain android APIs that are only available in SDK 29+ but your project/build.gradle is saying "use SDK 27", your dependencies would be expecting to use APIs which wouldn't exist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM