react-native打包apk常见错误收集

Posted songdongdong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了react-native打包apk常见错误收集相关的知识,希望对你有一定的参考价值。

react-native 0.59打包报错,信息如下,根据错误信息是因为react-native-cookies的sdk版本问题导致的

 1 ./gradlew assembleRelease
 2 
 3 > Configure project :react-native-cookies
 4 WARNING: Configuration ‘compile‘ is obsolete and has been replaced with ‘implementation‘ and ‘api‘.
 5 It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
 6 WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.1.
 7 Android SDK Build Tools 28.0.3 will be used.
 8 To suppress this warning, remove "buildToolsVersion ‘25.0.2‘" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
 9 
10 > Configure project :react-native-webview
11 :react-native-webview:reactNativeAndroidRoot F:\WorkSpace\CP_HY\node_modules\react-native\android
12 
13 > Task :app:bundleReleaseJsAndAssets
14 warning: the transform cache was reset.
15 Loading dependency graph, done.
16 info Writing bundle output to:, F:\WorkSpace\CP_HY\android\app\build\generated\assets\react\release\index.android.bundle
17 info Done writing bundle output
18 info Copying 50 asset files
19 info Done copying assets
20 
21 > Task :react-native-cookies:verifyReleaseResources FAILED
22 
23 FAILURE: Build failed with an exception.
24 
25 * What went wrong:
26 Execution failed for task ‘:react-native-cookies:verifyReleaseResources‘.
27 > java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
28   error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
29   error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.

根据错误信息,我们找到react-native-cookies下的andorid/build.gradle,修改skd版本如下

android 
    compileSdkVersion 28 // 23 ->28
    buildToolsVersion "28.0.3" // 25.0.2 -> 28.0.3

    defaultConfig 
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    
    lintOptions 
        abortOnError false
    

重新打包即可;

一般打包react-native应用时,最常见的错误就是第三方插件的sdk版本和react-native中android中的sdk版本不一致导致,这个时候不要慌,修改版本依赖,重新打包即可

以上是关于react-native打包apk常见错误收集的主要内容,如果未能解决你的问题,请参考以下文章

安卓转战React-Native之签名打包成Apk并极速多渠道打包

React-native APK打包

安卓转战React-Native之签名打包成Apk并极速多渠道打包

react-native打包apk报错

react-native 打包成apk 文件

react-native 打包Apk实践版