React Native:执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade 时发生故障

AhC*_*g11 2 node.js npm react-native

AAPT:错误:资源 android:未找到 attr/IStar。

这个错误突然发生,上周还正常。

在此输入图像描述

我尝试了很多解决方案,但没有一个有效。尝试过的解决方案:

  1. 删除,重新安装npm,使用npm install
  2. ./gradlew clean在 /android中清理 gradle
  3. 清理 npm 缓存npm cache clean --force
  4. 添加org.gradle.jvmargs=-Xmx4608m到/android/gradle.properties
  5. 在/android/build.gradle中,里面ext{}添加androidXCore = "1.6.0"
  6. npm update @react-native-community/netinfo
  7. androidx.core:core-ktx:+ 到 androidx.core:core-ktx:1.6.0 但我搜索过我的项目,没有“androidx.core:core-ktx:+”。所以我发现的这个解决方案是无关紧要的。

版本:

"react-native": "0.63.4",

compileSdkVersion = 29
targetSdkVersion = 29
Run Code Online (Sandbox Code Playgroud)

Tha*_*P A 7

将其添加到您的android/buld.gradle文件中。

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
        }
    }
Run Code Online (Sandbox Code Playgroud)

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