首页 > 解决方案 > React Native 构建签名的 apk 任务:app:signingConfigWriterRelease FAILED

问题描述

我正在尝试构建签名的 apk 但是当我尝试

./gradlew bundleRelease

它抛出:

Task :app:signingConfigWriterRelease FAILED 

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:signingConfigWriterRelease'.
> Trailing char < > at index 71: C:\Users\..\..\..\myProject\android\app\my-upload-key.keystore

SigningConfigs 和 buildTypes :

signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }

我不知道为什么,但是由于这个问题,我几天都无法获得签名的 apk。我需要做什么来解决这个问题?

标签: react-nativesigned-apk

解决方案


删除signingConfig signingConfigs.debug 内部发布块

buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug // try deleting this
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }

gradle.properties

MYAPP_RELEASE_STORE_FILE=my-upload-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=XXXXX
MYAPP_RELEASE_KEY_PASSWORD=XXXX

推荐阅读