任务 ':react-native-agconnect-remoteconfig:verifyReleaseResources' 失败

Task ':react-native-agconnect-remoteconfig:verifyReleaseResources' FAILED

我试图构建一个发布 apk,但我收到了这个错误。我检查了文件。它存在!

* What went wrong:
Execution failed for task ':react-native-agconnect-remoteconfig:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource compilation failed
     AAPT: /Users/xxx/com.xxx.xxx/node_modules/@react-native-agconnect/remoteconfig/android/build/intermediates/res/merged/release/layout/abc_alert_dialog_button_bar_material.xml: error: file not found.

我试过的:

在 android/build.gradle 中添加了以下代码:

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

我该如何解决这个问题?

添加以下代码后,请确保您使用的是兼容的 compileSdkVersion & buildToolsVersion :

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

然后

cd android && ./gradlew clean && ./gradlew app:assembleRelease

P.S。 ./gradlew assembleRelease 不起作用,但您可以使用 Android Studio 或上面的脚本构建 apk