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版本不一致导致,这个时候不要慌,修改版本依赖,重新打包即可

posted @ 2019-06-05 12:07  豆浆油条123  阅读(3309)  评论(0编辑  收藏  举报