expo sdk 52 android 构建失败

问题描述 投票:0回答:1

我已将我的应用程序升级到 Expo SDK 52,iOS 构建正常,但我的 Android 构建由于 AndroidManifest.xml 合并冲突而失败。这是 EAS 的输出:

[RUN_GRADLEW] FAILURE: Build failed with an exception.
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] Execution failed for task ':app:processReleaseMainManifest'.
[RUN_GRADLEW] > Manifest merger failed : Attribute property#android.adservices.AD_SERVICES_CONFIG@resource value=(@xml/ga_ad_services_config) from [com.google.android.gms:play-services-measurement-api:22.1.2] AndroidManifest.xml:32:13-58
[RUN_GRADLEW]       is also present at [com.facebook.android:facebook-core:18.0.0] AndroidManifest.xml:57:13-55 value=(@xml/ad_services_config).
[RUN_GRADLEW]       Suggestion: add 'tools:replace="android:resource"' to <property> element at AndroidManifest.xml to override.

在调试时,我发现删除

@react-native-firebase/analytics
react-native-fbsdk-next
之一可以解决问题(可能是因为不再存在明显的合并冲突)。

我尝试添加一个配置插件,以使用以下代码添加此错误中建议的

<property>
标签:

const { AndroidConfig, withAndroidManifest } = require('@expo/config-plugins');

function withAndroidManifestMergerRulesFix(config) {
  return withAndroidManifest(config, async (config) => {
    const mainApplication = AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
    const resourceName = 'android.adservices.AD_SERVICES_CONFIG';
    const conflictResolvingPropertyTag = {
      $: {
        'android:name': resourceName,
        'android:resource': '@xml/gma_ad_services_config',
        'tools:replace': 'android:resource',
      },
    };
    if (mainApplication['property']) {
      const existingPropertyTags = mainApplication['property'].filter(
        (res) => res.$['android:name'] !== resourceName,
      );
      existingPropertyTags.push(conflictResolvingPropertyTag);
    } else {
      mainApplication['property'] = [conflictResolvingPropertyTag];
    }

    return config;
  });
}

module.exports = withAndroidManifestMergerRulesFix;

这会导致不同的错误:

[RUN_GRADLEW] FAILURE: Build failed with an exception.
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] Execution failed for task ':app:processReleaseResources'.
[RUN_GRADLEW] > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
[RUN_GRADLEW]    > Android resource linking failed
[RUN_GRADLEW]      ERROR: /private/var/folders/tq/fg72n0nj36g7klqjj4yh67980000gn/T/eas-build-local-nodejs/fdcabbe1-4a0d-4573-a0f6-52b8351035d0/build/android/app/src/main/AndroidManifest.xml:71:5-149: AAPT: error: resource xml/gma_ad_services_config (aka com.growmaple.android:xml/gma_ad_services_config) not found.

到目前为止我还无法找到这些问题的答案。与我所看到的最接近的事情是解决方案是将

com.google.android.gms:play-services-ads
从 23.0.0 降级到 22.3.0 或将
AGP
恢复到 8.2.2。我不确定这在 Expo 应用程序中是否是一个可行的选择。

参考:Android项目实现admob时出现的问题

我已经更新了应用程序中的库并探索了我所知道的可能性。我需要 facebook 和 firebase 库,因此删除其中一个不是一种选择。

请帮忙!

android react-native expo eas
1个回答
0
投票

幸运的是,我一直在处理完全相同的问题

© www.soinside.com 2019 - 2024. All rights reserved.