Search code examples
androidreact-nativereact-native-config

Upgrade ReactNative to 0.55.4 and android build compile with error


The build is failing after updating project to RN ^0.55.4

Seems like the problem is relating with the react-native-config dependency Android BuildVersion 23.0.1

The android bin is deprecated and we'll use sdkmanager instead.

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

26.1.1

Some dependencies version:

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

Compilation error:

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

More description in your repo

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

Edit - It's a RN issue

Now I know it's a ReactNative issue, so I created one:

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

Please anyone can help me?


Solution

  • Try add android.enableAapt2=false in android/gradle.properties.
    Ref: https://github.com/facebook/react-native/issues/16906

    Or add this in 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 is the version used in /android/app/build.gradle buildToolsVersion For Gradle v4.4, the minimum version is 27.0.3.

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