React Native:生成Release Build APK错误:app:mergeReleaseAssets失败

时间:2018-09-21 09:55:39

标签: android react-native gradle android-ndk signed-apk

我正在尝试为React Native应用创建签名的APK。调试应用程序运行正常。 我正在按照react native guide创建签名的APK。

我已将密钥库添加到应用程序并设置gradle变量,但是无法进行签名的apk。

以下是assembleRelease构建的错误

./gradlew assembleRelease --stacktrace

    NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /home/anuragdhunna/Android/Sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /home/anuragdhunna/Android/Sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

:app:preBuild UP-TO-DATE
    :app:preReleaseBuild UP-TO-DATE
    :app:checkReleaseManifest
    :app:preDebugBuild UP-TO-DATE
    :app:prepareAndroidArchLifecycleRuntime100Library
    :app:prepareComAndroidSupportAnimatedVectorDrawable2610Library
    :app:prepareComAndroidSupportAppcompatV72610Library
    :app:prepareComAndroidSupportSupportCompat2610Library
    :app:prepareComAndroidSupportSupportCoreUi2610Library
    :app:prepareComAndroidSupportSupportCoreUtils2610Library
    :app:prepareComAndroidSupportSupportFragment2610Library
    :app:prepareComAndroidSupportSupportMediaCompat2610Library
    :app:prepareComAndroidSupportSupportV42610Library
    :app:prepareComAndroidSupportSupportVectorDrawable2610Library
    :app:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library
    :app:prepareComFacebookFrescoDrawee190Library
    :app:prepareComFacebookFrescoFbcore190Library
    :app:prepareComFacebookFrescoFresco190Library
    :app:prepareComFacebookFrescoImagepipeline190Library
    :app:prepareComFacebookFrescoImagepipelineBase190Library
    :app:prepareComFacebookFrescoImagepipelineOkhttp3190Library
    :app:prepareComFacebookReactReactNative0560Library
    :app:prepareComFacebookSoloaderSoloader030Library
    :app:prepareOrgWebkitAndroidJscR174650Library
    :react-native-splash-screen:preBuild UP-TO-DATE
    :react-native-splash-screen:preReleaseBuild UP-TO-DATE
    :react-native-splash-screen:checkReleaseManifest
    :react-native-splash-screen:preDebugAndroidTestBuild UP-TO-DATE
    :react-native-splash-screen:preDebugBuild UP-TO-DATE
    :react-native-splash-screen:preDebugUnitTestBuild UP-TO-DATE
    :react-native-splash-screen:preReleaseUnitTestBuild UP-TO-DATE
    :react-native-splash-screen:prepareAndroidArchLifecycleRuntime100Library
    :react-native-splash-screen:prepareComAndroidSupportAnimatedVectorDrawable2610Library
    :react-native-splash-screen:prepareComAndroidSupportAppcompatV72610Library
    :react-native-splash-screen:prepareComAndroidSupportSupportCompat2610Library
    :react-native-splash-screen:prepareComAndroidSupportSupportCoreUi2610Library
    :react-native-splash-screen:prepareComAndroidSupportSupportCoreUtils2610Library
    :react-native-splash-screen:prepareComAndroidSupportSupportFragment2610Library
    :react-native-splash-screen:prepareComAndroidSupportSupportMediaCompat2610Library
    :react-native-splash-screen:prepareComAndroidSupportSupportV42610Library
    :react-native-splash-screen:prepareComAndroidSupportSupportVectorDrawable2610Library
    :react-native-splash-screen:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library
    :react-native-splash-screen:prepareComFacebookFrescoDrawee190Library
    :react-native-splash-screen:prepareComFacebookFrescoFbcore190Library
    :react-native-splash-screen:prepareComFacebookFrescoFresco190Library
    :react-native-splash-screen:prepareComFacebookFrescoImagepipeline190Library
    :react-native-splash-screen:prepareComFacebookFrescoImagepipelineBase190Library
    :react-native-splash-screen:prepareComFacebookFrescoImagepipelineOkhttp3190Library
    :react-native-splash-screen:prepareComFacebookReactReactNative0560Library
    :react-native-splash-screen:prepareComFacebookSoloaderSoloader030Library
    :react-native-splash-screen:prepareOrgWebkitAndroidJscR174650Library
    :react-native-splash-screen:prepareReleaseDependencies
    :react-native-splash-screen:compileReleaseAidl UP-TO-DATE
    :react-native-splash-screen:compileReleaseNdk NO-SOURCE
    :react-native-splash-screen:compileLint UP-TO-DATE
    :react-native-splash-screen:copyReleaseLint NO-SOURCE
    :react-native-splash-screen:compileReleaseRenderscript UP-TO-DATE
    :react-native-splash-screen:generateReleaseBuildConfig UP-TO-DATE
    :react-native-splash-screen:generateReleaseResValues UP-TO-DATE
    :react-native-splash-screen:generateReleaseResources UP-TO-DATE
    :react-native-splash-screen:mergeReleaseResources UP-TO-DATE
    :react-native-splash-screen:processReleaseManifest UP-TO-DATE
    :react-native-splash-screen:processReleaseResources UP-TO-DATE
    :react-native-splash-screen:generateReleaseSources UP-TO-DATE
    :react-native-splash-screen:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
    :react-native-splash-screen:javaPreCompileRelease
    :react-native-splash-screen:compileReleaseJavaWithJavac UP-TO-DATE
    :react-native-splash-screen:extractReleaseAnnotations UP-TO-DATE
    :react-native-splash-screen:mergeReleaseShaders UP-TO-DATE
    :react-native-splash-screen:compileReleaseShaders UP-TO-DATE
    :react-native-splash-screen:generateReleaseAssets UP-TO-DATE
    :react-native-splash-screen:mergeReleaseAssets UP-TO-DATE
    :react-native-splash-screen:mergeReleaseProguardFiles UP-TO-DATE
    :react-native-splash-screen:packageReleaseRenderscript NO-SOURCE
    :react-native-splash-screen:packageReleaseResources UP-TO-DATE
    :react-native-splash-screen:processReleaseJavaRes NO-SOURCE
    :react-native-splash-screen:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
    :react-native-splash-screen:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
    :react-native-splash-screen:mergeReleaseJniLibFolders UP-TO-DATE
    :react-native-splash-screen:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE
    :react-native-splash-screen:transformNativeLibsWithSyncJniLibsForRelease UP-TO-DATE
    :react-native-splash-screen:bundleRelease UP-TO-DATE
    :app:prepareReleaseDependencies
    :app:compileReleaseAidl UP-TO-DATE
    :app:compileReleaseRenderscript UP-TO-DATE
    :app:generateReleaseBuildConfig UP-TO-DATE
    :app:mergeReleaseShaders UP-TO-DATE
    :app:compileReleaseShaders UP-TO-DATE
    :app:generateReleaseAssets UP-TO-DATE
    :app:mergeReleaseAssets FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:mergeReleaseAssets'.
    > java.io.IOException: Could not delete path '/home/anuragdhunna/projects/stu/tnpsuite/android/app/build/intermediates/assets/release/fonts/SimpleLineIcons.ttf'.

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

    BUILD FAILED

此外,我心中还有一个问题,为什么我面对NDK警告而不使用ndk,我有SDK平台工具。我该如何删除NDK警告,任何猜测?

2 个答案:

答案 0 :(得分:0)

如果./gradlew clean无法解决问题,则可以尝试以下操作:

  1. ReactNativeApp/android/build目录重命名为old.build
  2. 关闭Android Studio
  3. 在ReactNativeApp / android内部执行./gradlew clean
  4. 然后最后执行命令./gradlew assembleRelease

答案 1 :(得分:0)

  1. 关于SimpleLineIcons.ttf的错误与NDK警告无关。
  2. 警告是由ReactNative引起的,ReactNative尚未在最新版本的NDK和Android Studio中采用。
  3. 您现在可以忽略这些警告。