Home > Software engineering >  React Native: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$Act
React Native: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$Act

Time:11-07

AAPT: error: resource android: attr/IStar not found.

This error occurred suddenly, it was working fine last week.

enter image description here

I've tried many solutions but none works. Solutions tried:

  1. Delete, reinstall npm, using npm install
  2. clean gradle with ./gradlew clean in /android
  3. Cleaning npm cache with npm cache clean --force
  4. add org.gradle.jvmargs=-Xmx4608m in /android/gradle.properties
  5. In /android/build.gradle, inside ext{} add androidXCore = "1.6.0"
  6. npm update @react-native-community/netinfo
  7. androidx.core:core-ktx: to androidx.core:core-ktx:1.6.0 but I've searched through my project, there is no 'androidx.core:core-ktx: . So this solution I found is irrelevant.

Version:

"react-native": "0.63.4",

compileSdkVersion = 29
targetSdkVersion = 29

CodePudding user response:

Add this in your android/buld.gradle file.

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.65 , as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:"   REACT_NATIVE_VERSION
        }
    }

Ref : https://github.com/facebook/react-native/issues/35210

CodePudding user response:

There had been a series of build failures React Native & Expo users have been experiencing when building Android apps starting from November 4th 2022. Your issue is the same.

Since you are using React-native 0.63 React-native has a new patch released for it. try updating your react-native in your package.json from "react-native": "^0.63.4" to "react-native": "^0.63.5" and try running npm install and everything will work fine.

The suggested answer by Thanhal will give you some headaches if you try to upgrade to a new version of react-native and forget to remove it from build.gradle.

for more info please refer to This issue on github

  • Related