[react-native] Version 0.57 Packing Error, SDK Version Mismatch: Execution failed for task'xxx: verify Release Resources'

Keywords: Mobile Gradle React Android SDK

react-native version: 0.57.1

This is not an rn version problem, because 0.57.1 updates the Android SDK version to 27, which is incompatible with most third-party plug-ins that use native code, because third-party updates are not timely, SDK is still the old version.

Let's start with the error log:

error: invalid file path 'D:\xxx\node_modules\react-native-version-number\android\build\intermediates\manifests\aapt\release\AndroidManifest.xml'.

> Task :react-native-version-number:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-version-number:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3m 22s
156 actionable tasks: 16 executed, 140 up-to-date

This is a mistake that only happens when you pack the apk. There are two things you should pay attention to to to make sure that your mistake is the same kind as the one I encountered.

1."verifyReleaseResources"

2."Aapt2Exception"

Solution:

1. First, find build.gradle in the error-reporting package in node_modules, such as I'm node_modules react-native-version-number android build.gradle;

2. Modify the build.gradle to be consistent with the SDK version in android/build.gradle (or possibly android/app/build.gradle);

3. Change the compile in build.gradle to implementation because the compile is out of date.

android {
    compileSdkVersion 27 // 23 -> 27
    buildToolsVersion "27.0.3" // 23.0.1 -> 27.0.3

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 26 // 22 -> 26
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    lintOptions {
       warning 'InvalidPackage'
    }
}

dependencies {
    implementation 'com.facebook.react:react-native:+' // compile -> implementation
}

Then it's good to redistribute it.

Posted by DeadFly on Thu, 24 Jan 2019 16:00:13 -0800