【react-native】0.57版本打包错误,SDK版本不匹配问题:Execution failed for task 'xxx:verifyReleaseResources'

react-native版本:0.57.1

这个问题原本不是rn版本的问题,原因是0.57.1将Android SDK的版本更新到27了,这与大多第三方使用了原生代码的插件不兼容了,因为第三方更新不及时,SDK还是旧的版本。

先来看下错误日志: 

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

这个是只有打包apk时才会出现的错误,需要注意两个地方来确定你的错误和我遇到的是同一类错误:

1."verifyReleaseResources"

2."Aapt2Exception"

解决方案:

1.首先在node_modules中找到报错的包里面的build.gradle,比如我这个就是\node_modules\react-native-version-number\android\build.gradle;

2.修改这个build.gradle,使其与android/build.gradle(也可能是android/app/build.gradle)里面的SDK版本保持一致;

3.将build.gradle里的compile改为implementation,因为compile已过时。

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
}

然后重新发布就好了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

公西雒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值