将 ReactNative 升级到 0.55.4 并且 android build 编译出错

Upgrade ReactNative to 0.55.4 and android build compile with error

将项目更新为 RN 后构建失败 ^0.55.4

似乎问题与 react-native-config 依赖关系 Android BuildVersion 23.0.1

有关

android bin 已弃用,我们将使用 sdkmanager 代替。

$ ~/Android-sdk/tools/bin/sdkmanager --version

26.1.1

一些依赖版本:

"react": "^16.3.2",
"react-native": "^0.55.4",
"react-native-calendars": "^1.19.3",
"react-native-config": "^0.11.5",

编译错误:

Merging result:SUCCESS
Merged manifest saved to /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/bundles/release/AndroidManifest.xml
:react-native-config:processReleaseManifest (Thread[main,5,main]) completed. Took 0.116 secs.
:react-native-config:processReleaseResources (Thread[main,5,main]) started.
:react-native-config:processReleaseResources
Executing task ':react-native-config:processReleaseResources' (up-to-date check took 0.016 secs) due to:
  Output file /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/incremental/processReleaseResources has changed.
  Output file /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/generated/source/r/release has changed.
  Output file /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/generated/source/r/release/com has been removed.
All input files are considered out-of-date for incremental task ':react-native-config:processReleaseResources'.
Starting process 'command '/home/paneladm/Android-sdk/build-tools/23.0.1/aapt''. Working directory: /home/paneladm/my-react-native-app/node_modules/react-native-config/android Command: /home/paneladm/Android-sdk/build-tools/23.0.1/aapt package -f --no-crunch -I /home/paneladm/Android-sdk/platforms/android-23/android.jar -M /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/manifests/aapt/release/AndroidManifest.xml -S /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/res/merged/release -m -J /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/generated/source/r/release --custom-package com.lugg.ReactNativeConfig --non-constant-id -0 apk --output-text-symbols /home/paneladm/my-react-native-app/node_modules/react-native-config/android/build/intermediates/bundles/release --no-version-vectors
:react-native-config:processReleaseResources FAILED
:react-native-config:processReleaseResources (Thread[main,5,main]) completed. Took 0.123 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-config:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

您的存储库中有更多描述

https://github.com/luggit/react-native-config/issues/254

编辑 - 这是一个 RN 问题

现在我知道这是一个 ReactNative 问题,所以我创建了一个:

https://github.com/facebook/react-native/issues/19467

请问有人能帮帮我吗?

尝试在 android/gradle.properties 中添加 android.enableAapt2=false
参考:https://github.com/facebook/react-native/issues/16906

或在 android/app/build.gradle

中添加
subprojects {
  project.configurations.all {
      afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 26
                buildToolsVersion '26.0.2'
            }
        }
    }
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
           details.useVersion "26.0.2"
        }
     }
  }
}

26.0.2 是 /android/app/build.gradle buildToolsVersion 中使用的版本 对于Gradle v4.4,最低版本为27.0.3。

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